Skip to content

Most visited

Recently visited

navigation
Added in API level 1

Connection

public interface Connection
implements Wrapper, AutoCloseable

java.sql.Connection


A connection represents a link from a Java application to a database. All SQL statements and results are returned within the context of a connection. Database statements that are executed within this context form a database session which forms one or more closed transactions. Especially in distributed applications, multiple concurrent connections may exist accessing the same values of the database. which may lead to the following phenomena (referred to as transaction isolation levels):

Summary

Constants

int TRANSACTION_NONE

A constant indicating that transactions are not supported.

int TRANSACTION_READ_COMMITTED

No dirty reads are permitted, therefore transactions may not read a row containing uncommitted values - but does not prevent an application from non-repeatable reads and phantom reads.

int TRANSACTION_READ_UNCOMMITTED

In the case that reading uncommitted values is allowed, the following incidents may happen which may lead to an invalid results:

  • dirty reads
  • non-repeatable reads
  • phantom reads

int TRANSACTION_REPEATABLE_READ

A constant indicating that dirty reads and non-repeatable reads are prevented but phantom reads can occur.

int TRANSACTION_SERIALIZABLE

The constant that indicates that the following incidents are all prevented (the opposite of TRANSACTION_READ_UNCOMMITTED):

  • dirty reads
  • non-repeatable reads
  • phantom reads

Public methods

abstract void clearWarnings()

Discards all warnings that may have arisen for this connection.

abstract void close()

Causes the instant release of all database and driver connection resources associated with this object.

abstract void commit()

Commits all of the changes made since the last commit or rollback of the associated transaction.

abstract Array createArrayOf(String typeName, Object[] elements)

Returns a new Array containing the given elements.

abstract Blob createBlob()

Returns a new empty Blob.

abstract Clob createClob()

Returns a new empty Clob.

abstract NClob createNClob()

Returns a new empty NClob.

abstract SQLXML createSQLXML()

Returns a new empty SQLXML.

abstract Statement createStatement(int resultSetType, int resultSetConcurrency)

Returns a new instance of Statement whose associated ResultSets have the characteristics specified in the type and concurrency arguments.

abstract Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Returns a new instance of Statement whose associated ResultSets will have the characteristics specified in the type, concurrency and holdability arguments.

abstract Statement createStatement()

Returns a new instance of Statement for issuing SQL commands to the remote database.

abstract Struct createStruct(String typeName, Object[] attributes)

Returns a new Struct containing the given attributes.

abstract boolean getAutoCommit()

Returns a boolean indicating whether or not this connection is in the auto-commit operating mode.

abstract String getCatalog()

Gets this Connection object's current catalog name.

abstract String getClientInfo(String name)

Returns the value corresponding to the given client info property, or null if unset.

abstract Properties getClientInfo()

Returns a Properties object containing all client info properties.

abstract int getHoldability()

Returns the holdability property that any ResultSet produced by this instance will have.

abstract DatabaseMetaData getMetaData()

Gets the metadata about the database referenced by this connection.

abstract int getTransactionIsolation()

Returns the transaction isolation level for this connection.

abstract Map<StringClass<?>> getTypeMap()

Returns the type mapping associated with this Connection object.

abstract SQLWarning getWarnings()

Gets the first instance of any SQLWarning objects that may have been created in the use of this connection.

abstract boolean isClosed()

Returns a boolean indicating whether or not this connection is in the closed state.

abstract boolean isReadOnly()

Returns a boolean indicating whether or not this connection is currently in the read-only state.

abstract boolean isValid(int timeout)

Returns true if this connection is still open and valid, false otherwise.

abstract String nativeSQL(String sql)

Returns a string representation of the input SQL statement sql expressed in the underlying system's native SQL syntax.

abstract CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database.

abstract CallableStatement prepareCall(String sql)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database.

abstract CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database.

abstract PreparedStatement prepareStatement(String sql, String[] columnNames)

Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array.

abstract PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)

Creates a PreparedStatement that generates ResultSets with the specified values of resultSetType and resultSetConcurrency.

abstract PreparedStatement prepareStatement(String sql)

Returns a new instance of PreparedStatement that may be used any number of times to execute parameterized requests on the database server.

abstract PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)

Creates a default PreparedStatement that can retrieve automatically generated keys.

abstract PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)

Creates a PreparedStatement that generates ResultSets with the specified type, concurrency and holdability

abstract PreparedStatement prepareStatement(String sql, int[] columnIndexes)

Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array.

abstract void releaseSavepoint(Savepoint savepoint)

Releases the specified savepoint from the present transaction.

abstract void rollback()

Rolls back all updates made so far in this transaction and relinquishes all acquired database locks.

abstract void rollback(Savepoint savepoint)

Undoes all changes made after the supplied Savepoint object was set.

abstract void setAutoCommit(boolean autoCommit)

Sets this connection's auto-commit mode on or off.

abstract void setCatalog(String catalog)

Sets the catalog name for this connection.

abstract void setClientInfo(String name, String value)

Sets the client info property name to value.

abstract void setClientInfo(Properties properties)

Replaces all client info properties with the name/value pairs from properties.

abstract void setHoldability(int holdability)

Sets the holdability of the ResultSets created by this Connection.

abstract void setReadOnly(boolean readOnly)

Sets this connection to read-only mode.

abstract Savepoint setSavepoint(String name)

Creates a named Savepoint in the current transaction.

abstract Savepoint setSavepoint()

Creates an unnamed Savepoint in the current transaction.

abstract void setTransactionIsolation(int level)

Sets the transaction isolation level for this Connection.

abstract void setTypeMap(Map<StringClass<?>> map)

Sets the TypeMap for this connection.

Inherited methods

From interface java.sql.Wrapper
From interface java.lang.AutoCloseable

Constants

TRANSACTION_NONE

Added in API level 1
int TRANSACTION_NONE

A constant indicating that transactions are not supported.

Constant Value: 0 (0x00000000)

TRANSACTION_READ_COMMITTED

Added in API level 1
int TRANSACTION_READ_COMMITTED

No dirty reads are permitted, therefore transactions may not read a row containing uncommitted values - but does not prevent an application from non-repeatable reads and phantom reads.

Constant Value: 2 (0x00000002)

TRANSACTION_READ_UNCOMMITTED

Added in API level 1
int TRANSACTION_READ_UNCOMMITTED

In the case that reading uncommitted values is allowed, the following incidents may happen which may lead to an invalid results:

  • dirty reads
  • non-repeatable reads
  • phantom reads

Constant Value: 1 (0x00000001)

TRANSACTION_REPEATABLE_READ

Added in API level 1
int TRANSACTION_REPEATABLE_READ

A constant indicating that dirty reads and non-repeatable reads are prevented but phantom reads can occur.

Constant Value: 4 (0x00000004)

TRANSACTION_SERIALIZABLE

Added in API level 1
int TRANSACTION_SERIALIZABLE

The constant that indicates that the following incidents are all prevented (the opposite of TRANSACTION_READ_UNCOMMITTED):

  • dirty reads
  • non-repeatable reads
  • phantom reads

Constant Value: 8 (0x00000008)

Public methods

clearWarnings

Added in API level 1
void clearWarnings ()

Discards all warnings that may have arisen for this connection. Subsequent calls to getWarnings() will return null up until a new warning condition occurs.

Throws
SQLException if there is a problem accessing the database.

close

Added in API level 1
void close ()

Causes the instant release of all database and driver connection resources associated with this object. Any subsequent invocations of this method have no effect.

It is strongly recommended that all connections are closed before they are dereferenced by the application ready for garbage collection. Although the finalize method of the connection closes the connection before garbage collection takes place, it is not advisable to leave the close operation to take place in this way. Mainly because undesired side-effects may appear.

Throws
SQLException if there is a problem accessing the database.

commit

Added in API level 1
void commit ()

Commits all of the changes made since the last commit or rollback of the associated transaction. All locks in the database held by this connection are also relinquished. Calling this operation on connection objects in auto-commit mode leads to an error.

Throws
SQLException if there is a problem accessing the database or if the target connection instance is in auto-commit mode.

createArrayOf

Added in API level 9
Array createArrayOf (String typeName, 
                Object[] elements)

Returns a new Array containing the given elements.

Parameters
typeName String: the SQL name of the type of the array elements
elements Object
Returns
Array
Throws
SQLClientInfoException if this connection is closed, or there's a problem creating the array.
SQLException

createBlob

Added in API level 9
Blob createBlob ()

Returns a new empty Blob.

Returns
Blob
Throws
SQLException if this connection is closed, or there's a problem creating a new blob.

createClob

Added in API level 9
Clob createClob ()

Returns a new empty Clob.

Returns
Clob
Throws
SQLException if this connection is closed, or there's a problem creating a new clob.

createNClob

Added in API level 9
NClob createNClob ()

Returns a new empty NClob.

Returns
NClob
Throws
SQLException if this connection is closed, or there's a problem creating a new nclob.

createSQLXML

Added in API level 9
SQLXML createSQLXML ()

Returns a new empty SQLXML.

Returns
SQLXML
Throws
SQLException if this connection is closed, or there's a problem creating a new XML.

createStatement

Added in API level 1
Statement createStatement (int resultSetType, 
                int resultSetConcurrency)

Returns a new instance of Statement whose associated ResultSets have the characteristics specified in the type and concurrency arguments.

Parameters
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
Returns
Statement a new instance of Statement capable of manufacturing ResultSets that satisfy the specified resultSetType and resultSetConcurrency values.
Throws
SQLException if there is a problem accessing the database

createStatement

Added in API level 1
Statement createStatement (int resultSetType, 
                int resultSetConcurrency, 
                int resultSetHoldability)

Returns a new instance of Statement whose associated ResultSets will have the characteristics specified in the type, concurrency and holdability arguments.

Parameters
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
resultSetHoldability int: one of the following holdability mode specifiers:
Returns
Statement a new instance of Statement capable of manufacturing ResultSets that satisfy the specified resultSetType, resultSetConcurrency and resultSetHoldability values.
Throws
SQLException if there is a problem accessing the database.

createStatement

Added in API level 1
Statement createStatement ()

Returns a new instance of Statement for issuing SQL commands to the remote database.

ResultSets generated by the returned statement will default to type ResultSet.TYPE_FORWARD_ONLY and concurrency level ResultSet.CONCUR_READ_ONLY.

Returns
Statement a Statement object with default settings.
Throws
SQLException if there is a problem accessing the database.

See also:

createStruct

Added in API level 9
Struct createStruct (String typeName, 
                Object[] attributes)

Returns a new Struct containing the given attributes.

Parameters
typeName String: the SQL name of the type of the struct attributes
attributes Object
Returns
Struct
Throws
SQLClientInfoException if this connection is closed, or there's a problem creating the array.
SQLException

getAutoCommit

Added in API level 1
boolean getAutoCommit ()

Returns a boolean indicating whether or not this connection is in the auto-commit operating mode.

Returns
boolean true if auto-commit is on, otherwise false.
Throws
SQLException if there is a problem accessing the database.

getCatalog

Added in API level 1
String getCatalog ()

Gets this Connection object's current catalog name.

Returns
String the catalog name. null if there is no catalog name.
Throws
SQLException if there is a problem accessing the database.

getClientInfo

Added in API level 9
String getClientInfo (String name)

Returns the value corresponding to the given client info property, or null if unset.

Parameters
name String
Returns
String
Throws
SQLClientInfoException if this connection is closed, or there's a problem getting the property.
SQLException

getClientInfo

Added in API level 9
Properties getClientInfo ()

Returns a Properties object containing all client info properties.

Returns
Properties
Throws
SQLClientInfoException if this connection is closed, or there's a problem getting a property.
SQLException

getHoldability

Added in API level 1
int getHoldability ()

Returns the holdability property that any ResultSet produced by this instance will have.

Returns
int one of the following holdability mode specifiers:
Throws
SQLException if there is a problem accessing the a database.

getMetaData

Added in API level 1
DatabaseMetaData getMetaData ()

Gets the metadata about the database referenced by this connection. The returned DatabaseMetaData describes the database topography, available stored procedures, SQL syntax and so on.

Returns
DatabaseMetaData a DatabaseMetaData object containing the database description.
Throws
SQLException if there is a problem accessing the a database.

getTransactionIsolation

Added in API level 1
int getTransactionIsolation ()

Returns the transaction isolation level for this connection.

Returns
int the transaction isolation value.
Throws
SQLException if there is a problem accessing the database.

See also:

getTypeMap

Added in API level 1
Map<StringClass<?>> getTypeMap ()

Returns the type mapping associated with this Connection object. The type mapping must be set on the application level.

Returns
Map<StringClass<?>> the Type Map as a java.util.Map.
Throws
SQLException if there is a problem accessing the database.

getWarnings

Added in API level 1
SQLWarning getWarnings ()

Gets the first instance of any SQLWarning objects that may have been created in the use of this connection. If at least one warning has occurred then this operation returns the first one reported. A null indicates that no warnings have occurred.

By invoking the getNextWarning() method of the returned SQLWarning object it is possible to obtain all of this connection's warning objects.

Returns
SQLWarning the first warning as an SQLWarning object (may be null).
Throws
SQLException if there is a problem accessing the database or if the call has been made on a connection which has been previously closed.

isClosed

Added in API level 1
boolean isClosed ()

Returns a boolean indicating whether or not this connection is in the closed state. The closed state may be entered into as a consequence of a successful invocation of the close() method or else if an error has occurred that prevents the connection from functioning normally.

Returns
boolean true if closed, otherwise false.
Throws
SQLException if there is a problem accessing the database.

isReadOnly

Added in API level 1
boolean isReadOnly ()

Returns a boolean indicating whether or not this connection is currently in the read-only state.

Returns
boolean true if in read-only state, otherwise false.
Throws
SQLException if there is a problem accessing the database.

isValid

Added in API level 9
boolean isValid (int timeout)

Returns true if this connection is still open and valid, false otherwise.

Parameters
timeout int: number of seconds to wait for a response before giving up and returning false, 0 to wait forever
Returns
boolean
Throws
SQLException if timeout < 0

nativeSQL

Added in API level 1
String nativeSQL (String sql)

Returns a string representation of the input SQL statement sql expressed in the underlying system's native SQL syntax.

Parameters
sql String: the JDBC form of an SQL statement.
Returns
String the SQL statement in native database format.
Throws
SQLException if there is a problem accessing the database

prepareCall

Added in API level 1
CallableStatement prepareCall (String sql, 
                int resultSetType, 
                int resultSetConcurrency)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database. ResultSets emitted from this CallableStatement will satisfy the specified resultSetType and resultSetConcurrency values.

Parameters
sql String: the SQL statement
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
Returns
CallableStatement a new instance of CallableStatement representing the precompiled SQL statement. ResultSets emitted from this CallableStatement will satisfy the specified resultSetType and resultSetConcurrency values.
Throws
SQLException if a problem occurs accessing the database

prepareCall

Added in API level 1
CallableStatement prepareCall (String sql)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database.

Parameters
sql String: the SQL statement that calls the stored function
Returns
CallableStatement a new instance of CallableStatement representing the SQL statement. ResultSets emitted from this CallableStatement will default to type TYPE_FORWARD_ONLY and concurrency CONCUR_READ_ONLY.
Throws
SQLException if a problem occurs accessing the database.

prepareCall

Added in API level 1
CallableStatement prepareCall (String sql, 
                int resultSetType, 
                int resultSetConcurrency, 
                int resultSetHoldability)

Returns a new instance of CallableStatement that may be used for making stored procedure calls to the database. ResultSets created from this CallableStatement will have characteristics determined by the specified type, concurrency and holdability arguments.

Parameters
sql String: the SQL statement
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
resultSetHoldability int: one of the following holdability mode specifiers:
Returns
CallableStatement a new instance of CallableStatement representing the precompiled SQL statement. ResultSets emitted from this CallableStatement will satisfy the specified resultSetType, resultSetConcurrency and resultSetHoldability values.
Throws
SQLException if a problem occurs accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql, 
                String[] columnNames)

Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array. If sql is an SQL INSERT statement, columnNames is expected to hold the names of each column in the statement's associated database table containing the autogenerated-keys of interest. Otherwise columnNames is ignored.

Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. Alternatively, if the driver is not capable of handling precompiled statements, the statement will not reach the database server until it is executed. This will have a bearing on precisely when SQLException instances get raised.

By default, ResultSets from the returned object will be TYPE_FORWARD_ONLY type with a CONCUR_READ_ONLY concurrency mode.

Parameters
sql String: the SQL statement.
columnNames String: the names of the columns for which auto-generated keys should be made available.
Returns
PreparedStatement the PreparedStatement containing the supplied SQL statement.
Throws
SQLException if a problem occurs accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql, 
                int resultSetType, 
                int resultSetConcurrency)

Creates a PreparedStatement that generates ResultSets with the specified values of resultSetType and resultSetConcurrency.

Parameters
sql String: the SQL statement. It can contain one or more '?' IN parameter placeholders.
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
Returns
PreparedStatement a new instance of PreparedStatement containing the SQL statement sql. ResultSets emitted from this PreparedStatement will satisfy the specified resultSetType and resultSetConcurrency values.
Throws
SQLException if a problem occurs accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql)

Returns a new instance of PreparedStatement that may be used any number of times to execute parameterized requests on the database server.

Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

By default, ResultSets from the returned object will be TYPE_FORWARD_ONLY type with a CONCUR_READ_ONLY mode of concurrency.

Parameters
sql String: the SQL statement.
Returns
PreparedStatement the PreparedStatement containing the supplied SQL statement.
Throws
SQLException if there is a problem accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql, 
                int autoGeneratedKeys)

Creates a default PreparedStatement that can retrieve automatically generated keys. Parameter autoGeneratedKeys may be used to tell the driver whether such keys should be made accessible. This is only relevant when the sql statement is an insert statement.

An SQL statement which may have IN parameters can be stored and precompiled in a PreparedStatement. The PreparedStatement can then be then be used to execute the statement multiple times in an efficient way.

Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

By default, ResultSets from the returned object will be TYPE_FORWARD_ONLY type with a CONCUR_READ_ONLY mode of concurrency.

Parameters
sql String: the SQL statement.
autoGeneratedKeys int: one of the following generated key options:
Returns
PreparedStatement a new PreparedStatement instance representing the input SQL statement.
Throws
SQLException if there is a problem accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql, 
                int resultSetType, 
                int resultSetConcurrency, 
                int resultSetHoldability)

Creates a PreparedStatement that generates ResultSets with the specified type, concurrency and holdability

Parameters
sql String: the SQL statement. It can contain one or more '?' IN parameter placeholders.
resultSetType int: one of the following type specifiers:
resultSetConcurrency int: one of the following concurrency mode specifiers:
resultSetHoldability int: one of the following holdability mode specifiers:
Returns
PreparedStatement a new instance of PreparedStatement containing the SQL statement sql. ResultSets emitted from this PreparedStatement will satisfy the specified resultSetType, resultSetConcurrency and resultSetHoldability values.
Throws
SQLException if a problem occurs accessing the database.

prepareStatement

Added in API level 1
PreparedStatement prepareStatement (String sql, 
                int[] columnIndexes)

Creates a default PreparedStatement that can retrieve the auto-generated keys designated by a supplied array. If sql is an SQL INSERT statement, the parameter columnIndexes is expected to hold the index values for each column in the statement's intended database table containing the autogenerated-keys of interest. Otherwise columnIndexes is ignored.

Subject to JDBC driver support, this operation will attempt to send the precompiled version of the statement to the database. If the driver does not support precompiled statements, the statement will not reach the database server until it is executed. This distinction determines the moment when SQLExceptions get raised.

By default, ResultSets from the returned object will be TYPE_FORWARD_ONLY type with a CONCUR_READ_ONLY concurrency mode.

Parameters
sql String: the SQL statement.
columnIndexes int: the indexes of the columns for which auto-generated keys should be made available.
Returns
PreparedStatement the PreparedStatement containing the supplied SQL statement.
Throws
SQLException if a problem occurs accessing the database.

releaseSavepoint

Added in API level 1
void releaseSavepoint (Savepoint savepoint)

Releases the specified savepoint from the present transaction. Once removed, the Savepoint is considered invalid and should not be referenced further.

Parameters
savepoint Savepoint: the object targeted for removal.
Throws
SQLException if there is a problem with accessing the database or if savepoint is considered not valid in this transaction.

rollback

Added in API level 1
void rollback ()

Rolls back all updates made so far in this transaction and relinquishes all acquired database locks. It is an error to invoke this operation when in auto-commit mode.

Throws
SQLException if there is a problem with the database or if the method is called while in auto-commit mode of operation.

rollback

Added in API level 1
void rollback (Savepoint savepoint)

Undoes all changes made after the supplied Savepoint object was set. This method should only be used when auto-commit mode is disabled.

Parameters
savepoint Savepoint: the Savepoint to roll back to
Throws
SQLException if there is a problem accessing the database.

setAutoCommit

Added in API level 1
void setAutoCommit (boolean autoCommit)

Sets this connection's auto-commit mode on or off.

Putting a Connection into auto-commit mode means that all associated SQL statements are run and committed as separate transactions. By contrast, setting auto-commit to off means that associated SQL statements get grouped into transactions that need to be completed by explicit calls to either the commit() or rollback() methods.

Auto-commit is the default mode for new connection instances.

When in this mode, commits will automatically occur upon successful SQL statement completion or upon successful completion of an execute. Statements are not considered successfully completed until all associated ResultSets and output parameters have been obtained or closed.

Calling this operation during an uncommitted transaction will result in it being committed.

Parameters
autoCommit boolean: boolean indication of whether to put the target connection into auto-commit mode (true) or not ( false).
Throws
SQLException if there is a problem accessing the database.

setCatalog

Added in API level 1
void setCatalog (String catalog)

Sets the catalog name for this connection. This is used to select a subspace of the database for future work. If the driver does not support catalog names, this method is ignored.

Parameters
catalog String: the catalog name to use.
Throws
SQLException if there is a problem accessing the database.

setClientInfo

Added in API level 9
void setClientInfo (String name, 
                String value)

Sets the client info property name to value. A value of null clears the client info property.

Parameters
name String
value String
Throws
SQLClientInfoException if this connection is closed, or there's a problem setting the property.

setClientInfo

Added in API level 9
void setClientInfo (Properties properties)

Replaces all client info properties with the name/value pairs from properties. All existing properties are removed. If an exception is thrown, the resulting state of this connection's client info properties is undefined.

Parameters
properties Properties
Throws
SQLClientInfoException if this connection is closed, or there's a problem setting a property.

setHoldability

Added in API level 1
void setHoldability (int holdability)

Sets the holdability of the ResultSets created by this Connection.

Parameters
holdability int: one of the following holdability mode specifiers:
Throws
SQLException if there is a problem accessing the database

setReadOnly

Added in API level 1
void setReadOnly (boolean readOnly)

Sets this connection to read-only mode.

This serves as a hint to the driver, which can enable database optimizations.

Parameters
readOnly boolean: true to set the Connection to read only mode. false disables read-only mode.
Throws
SQLException if there is a problem accessing the database.

setSavepoint

Added in API level 1
Savepoint setSavepoint (String name)

Creates a named Savepoint in the current transaction.

Parameters
name String: the name to use for the new Savepoint.
Returns
Savepoint a Savepoint object for this savepoint.
Throws
SQLException if there is a problem accessing the database.

setSavepoint

Added in API level 1
Savepoint setSavepoint ()

Creates an unnamed Savepoint in the current transaction.

Returns
Savepoint a Savepoint object for this savepoint.
Throws
SQLException if there is a problem accessing the database.

setTransactionIsolation

Added in API level 1
void setTransactionIsolation (int level)

Sets the transaction isolation level for this Connection.

If this method is called during a transaction, the results are implementation defined.

Parameters
level int: the new transaction isolation level to use from the following list of possible values:
Throws
SQLException if there is a problem with the database or if the value of level is not one of the expected constant values.

setTypeMap

Added in API level 1
void setTypeMap (Map<StringClass<?>> map)

Sets the TypeMap for this connection. The input map should contain mappings between complex Java and SQL types.

Parameters
map Map: the new type map.
Throws
SQLException if there is a problem accessing the database or if map is not an instance of Map.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.