Upload
pcdproyecto
View
224
Download
0
Embed Size (px)
Citation preview
8/12/2019 Connection (Java Platform Se 7 ) (1)
1/20
Overview Package Class Use Tree Deprecated Index HelpJava Platform
Standard Ed. 7
Prev Class Next Class Frames No Frames All Classes
Summary: Nested |Field| Constr | Method Detail:Field| Constr | Method
java.sql
Interface Connection
All Superinterfaces:
AutoCloseable, Wrapper
public interface Connectionextends Wrapper, AutoCloseable
A connection (session) with a specific database. SQL statements are executed and results are returned within the context of a connection.
AConnectionobject's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of thisconnection, and so on. This information is obtained with thegetMetaDatamethod.
Note:When configuring aConnection, JDBC applications should use the appropriateConnectionmethod such as setAutoCommitorsetTransactionIsolation. Applications should not invoke SQL commands directly to change the connection's configuration when there is a JDBC methodavailable. By default a Connectionobject is in auto-commit mode, which means that it automatically commits changes after executing each statement. If auto-commit mode has been disabled, the method commitmust be called explicitly in order to commit changes; otherwise, database changes will not be saved.
A newConnectionobject created using the JDBC 2.1 core API has an initially empty type map associated with it. A user may enter a custom mapping for a UDT in
this type map. When a UDT is retrieved from a data source with the method ResultSet.getObject, thegetObjectmethod will check the connection's type map tosee if there is an entry for that UDT. If so, the getObjectmethod will map the UDT to the class indicated. If there is no entry, the UDT will be mapped using thestandard mapping.
A user may create a new type map, which is ajava.util.Mapobject, make an entry in it, and pass it to the java.sqlmethods that can perform custom mapping.In this case, the method will use the given type map instead of the one associated with the connection.
For example, the following code fragment specifies that the SQL type ATHLETESwill be mapped to the class Athletesin the Java programming language. Thecode fragment retrieves the type map for the Connection objectcon, inserts the entry into it, and then sets the type map with the new entry as the connection's typemap.
java.util.Map map = con.getTypeMap();
map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));
con.setTypeMap(map);
See Also:
DriverManager.getConnection(java.lang.String, java.util.Properties),Statement,ResultSet,DatabaseMetaData
FieldSummary
Modifier and Type Field and Description
static int TRANSACTION_NONE
A constant indicating that transactions are not supported.
static int TRANSACTION_READ_COMMITTED
A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
static int TRANSACTION_READ_UNCOMMITTED
A constant indicating that dirty reads, non-repeatable reads and phantom reads can occur.
static int TRANSACTION_REPEATABLE_READA constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
static int TRANSACTION_SERIALIZABLE
A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented.
Method Summary
Modifier and Type Method and Description
void abort(Executorexecutor)
Terminates an open connection.
void clearWarnings()
Clears all warnings reported for this Connectionobject.
void close()
Releases this Connectionobject's database and JDBC resources immediately instead of waiting for them to beautomatically released.
void commit()
Fields
Methods
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 1 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_READ_UNCOMMITTEDhttp://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties)http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties)http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Wrapper.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Clob.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.htmlhttp://docs.oracle.com/javase/7/docs/api/index.html?java/sql/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#commit()http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#close()http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#clearWarnings()http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#abort(java.util.concurrent.Executor)http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_SERIALIZABLEhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_REPEATABLE_READhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_READ_UNCOMMITTEDhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_READ_COMMITTEDhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#TRANSACTION_NONEhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Statement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection(java.lang.String,%20java.util.Properties)http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Wrapper.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Wrapper.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.htmlhttp://docs.oracle.com/javase/7/docs/api/allclasses-noframe.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/index.html?java/sql/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Clob.htmlhttp://docs.oracle.com/javase/7/docs/api/help-doc.htmlhttp://docs.oracle.com/javase/7/docs/api/index-files/index-1.htmlhttp://docs.oracle.com/javase/7/docs/api/deprecated-list.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/package-tree.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/class-use/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/package-summary.htmlhttp://docs.oracle.com/javase/7/docs/api/overview-summary.html8/12/2019 Connection (Java Platform Se 7 ) (1)
2/20
Makes all changes made since the previous commit/rollback permanent and releases any database locks currentlyheld by this Connectionobject.
Array createArrayOf(StringtypeName, Object[] elements)
Factory method for creating Array objects.
Blob createBlob()
Constructs an object that implements the Blobinterface.
Clob createClob()
Constructs an object that implements the Clobinterface.
NClob createNClob()
Constructs an object that implements the NClobinterface.
SQLXML createSQLXML()Constructs an object that implements the SQLXMLinterface.
Statement createStatement()
Creates a Statementobject for sending SQL statements to the database.
Statement createStatement(int resultSetType, int resultSetConcurrency)
Creates a Statementobject that will generateResultSetobjects with the given type and concurrency.
Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Creates a Statementobject that will generateResultSetobjects with the given type, concurrency, and holdability.
Struct createStruct(StringtypeName, Object[] attributes)
Factory method for creating Struct objects.
boolean getAutoCommit()
Retrieves the current auto-commit mode for thisConnectionobject.
String getCatalog()
Retrieves this Connectionobject's current catalog name.Properties getClientInfo()
Returns a list containing the name and current value of each client info property supported by the driver.
String getClientInfo(Stringname)
Returns the value of the client info property specified by name.
int getHoldability()
Retrieves the current holdability of ResultSetobjects created using this Connectionobject.
DatabaseMetaData getMetaData()
Retrieves aDatabaseMetaDataobject that contains metadata about the database to which this Connectionobjectrepresents a connection.
int getNetworkTimeout()
Retrieves the number of mil liseconds the driver will wait for a database request to complete.
String getSchema()
Retrieves this Connectionobject's current schema name.int getTransactionIsolation()
Retrieves this Connectionobject's current transaction isolation level.
Map
8/12/2019 Connection (Java Platform Se 7 ) (1)
3/20
Creates a PreparedStatementobject that will generate ResultSetobjects with the given type, concurrency, andholdability.
PreparedStatement prepareStatement(Stringsql, String[] columnNames)
Creates a default PreparedStatementobject capable of returning the auto-generated keys designated by the givenarray.
void releaseSavepoint(Savepointsavepoint)
Removes the specified Savepointand subsequent Savepointobjects from the current transaction.
void rollback()
Undoes all changes made in the current transaction and releases any database locks currently held by thisConnectionobject.
void rollback(Savepointsavepoint)
Undoes all changes made after the given Savepointobject was set.
void setAutoCommit(boolean autoCommit)
Sets this connection's auto-commit mode to the given state.
void setCatalog(Stringcatalog)
Sets the given catalog name in order to select a subspace of this Connectionobject's database in which to work.
void setClientInfo(Propertiesproperties)
Sets the value of the connection's client info properties.
void setClientInfo(Stringname, Stringvalue)
Sets the value of the client info property specified by name to the value specified by value.
void setHoldability(int holdability)
Changes the default holdability ofResultSetobjects created using this Connectionobject to the given holdability.
void setNetworkTimeout(Executorexecutor, int milliseconds)
Sets the maximum period a Connectionor objects created from the Connectionwill wait for the database to reply
to any one request.
void setReadOnly(boolean readOnly)
Puts this connection in read-only mode as a hint to the driver to enable database optimizations.
Savepoint setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the newSavepointobject that represents it.
Savepoint setSavepoint(Stringname)
Creates a savepoint with the given name in the current transaction and returns the new Savepointobject thatrepresents it.
void setSchema(Stringschema)
Sets the given schema name to access.
void setTransactionIsolation(int level)
Attempts to change the transaction isolation level for this Connectionobject to the one given.
void setTypeMap(Map
8/12/2019 Connection (Java Platform Se 7 ) (1)
4/20
A constant indicating that dirty reads are prevented; non-repeatable reads and phantom reads can occur. This level only prohibits a transaction from readinga row with uncommitted changes in it.
See Also:
Constant Field Values
TRANSACTION_REPEATABLE_READ
static final int TRANSACTION_REPEATABLE_READ
A constant indicating that dirty reads and non-repeatable reads are prevented; phantom reads can occur. This level prohibits a transaction from reading arow with uncommitted changes in it, and it also prohibits the situation where one transaction reads a row, a second transaction alters the row, and the firsttransaction rereads the row, getting different values the second time (a "non-repeatable read").
See Also:
Constant Field Values
TRANSACTION_SERIALIZABLE
static final int TRANSACTION_SERIALIZABLE
A constant indicating that dirty reads, non-repeatable reads and phantom reads are prevented. This level includes the prohibitions inTRANSACTION_REPEATABLE_READand further prohibits the situation where one transaction reads all rows that satisfy aWHEREcondition, a secondtransaction inserts a row that satisfies thatWHEREcondition, and the first transaction rereads for the same condition, retrieving the additional "phantom" rowin the second read.
See Also:
Constant Field Values
Method Detail
createStatement
StatementcreateStatement()
throws SQLException
Creates a Statementobject for sending SQL statements to the database. SQL statements without parameters are normally executed using Statementobjects. If the same SQL statement is executed many times, it may be more efficient to use a PreparedStatementobject.
Result sets created using the returnedStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level of CONCUR_READ_ONLY.The holdability of the created result sets can be determined by calling getHoldability().
Returns:
a new default Statementobject
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
prepareStatement
PreparedStatementprepareStatement(Stringsql) throws SQLException
Creates a PreparedStatementobject for sending parameterized SQL statements to the database.
A SQL statement with or without IN parameters can be pre-compiled and stored in aPreparedStatementobject. This object can then be used to efficientlyexecute this statement multiple times.
Note:This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the methodprepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statementmay not be sent to the database until the PreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methodsthrow certainSQLExceptionobjects.
Result sets created using the returnedPreparedStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY. The holdability of the created result sets can be determined by callinggetHoldability().
Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholders
Returns:
a new default PreparedStatementobject containing the pre-compiled SQL statement
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 4 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Statement.htmlhttp://docs.oracle.com/javase/7/docs/api/constant-values.html#java.sql.Connection.TRANSACTION_SERIALIZABLEhttp://docs.oracle.com/javase/7/docs/api/constant-values.html#java.sql.Connection.TRANSACTION_REPEATABLE_READhttp://docs.oracle.com/javase/7/docs/api/constant-values.html#java.sql.Connection.TRANSACTION_READ_COMMITTED8/12/2019 Connection (Java Platform Se 7 ) (1)
5/20
prepareCall
CallableStatementprepareCall(Stringsql)
throws SQLException
Creates a CallableStatementobject for calling database stored procedures. TheCallableStatementobject provides methods for setting up its IN andOUT parameters, and methods for executing the call to a stored procedure.
Note:This method is optimized for handling stored procedure call statements. Some drivers may send the call statement to the database when the methodprepareCallis done; others may wait until the CallableStatementobject is executed. This has no direct effect on users; however, it does affect whichmethod throws certain SQLExceptions.
Result sets created using the returnedCallableStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY. The holdability of the created result sets can be determined by callinggetHoldability().
Parameters:
sql- an SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is specified using JDBC call escape syntax.
Returns:
a new default CallableStatementobject containing the pre-compiled SQL statement
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
nativeSQL
StringnativeSQL(Stringsql)
throws SQLException
Converts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC SQL grammar into its system's native SQLgrammar prior to sending it. This method returns the native form of the statement that the driver would have sent.
Parameters:
sql- an SQL statement that may contain one or more '?' parameter placeholders
Returns:
the native form of this statement
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
setAutoCommit
void setAutoCommit(boolean autoCommit)
throws SQLException
Sets this connection's auto-commit mode to the given state. If a connection is in auto-commit mode, then all its SQL statements will be executed andcommitted as individual transactions. Otherwise, its SQL statements are grouped into transactions that are terminated by a call to either the methodcommitor the method rollback. By default, new connections are in auto-commit mode.
The commit occurs when the statement completes. The time when the statement completes depends on the type of SQL Statement:
For DML statements, such as Insert, Update or Delete, and DDL statements, the statement is complete as soon as it has finished executing.For Select statements, the statement is complete when the associated result set is closed.ForCallableStatementobjects or for statements that return multiple results, the statement is complete when all of the associated result sets havebeen closed, and all update counts and output parameters have been retrieved.
NOTE:If this method is called during a transaction and the auto-commit mode is changed, the transaction is committed. IfsetAutoCommitis called and theauto-commit mode is not changed, the call is a no-op.
Parameters:
autoCommit-trueto enable auto-commit mode; falseto disable it
Throws:
SQLException- if a database access error occurs, setAutoCommit(true) is called while participating in a distributed transaction, or this method is calledon a closed connection
See Also:
getAutoCommit()
getAutoCommit
boolean getAutoCommit()
throws SQLException
Retrieves the current auto-commit mode for thisConnectionobject.
Returns:
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 5 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getAutoCommit()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.html8/12/2019 Connection (Java Platform Se 7 ) (1)
6/20
the current state of this Connectionobject's auto-commit mode
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
See Also:
setAutoCommit(boolean)
commit
void commit() throws SQLException
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by this Connectionobject. Thismethod should be used only when auto-commit mode has been disabled.
Throws:
SQLException- if a database access error occurs, this method is called while participating in a distributed transaction, if this method is called on aclosed conection or this Connectionobject is in auto-commit mode
See Also:
setAutoCommit(boolean)
rollback
void rollback() throws SQLException
Undoes all changes made in the current transaction and releases any database locks currently held by this Connectionobject. This method should beused only when auto-commit mode has been disabled.
Throws:
SQLException- if a database access error occurs, this method is called while participating in a distributed transaction, this method is called on aclosed connection or this Connectionobject is in auto-commit mode
See Also:
setAutoCommit(boolean)
close
void close() throws SQLException
Releases this Connectionobject's database and JDBC resources immediately instead of waiting for them to be automatically released.
Calling the method closeon a Connectionobject that is already closed is a no-op.
It is strongly recommendedthat an application explicitly commits or rolls back an active transaction prior to call ing the closemethod. If the closemethod iscalled and there is an active transaction, the results are implementation-defined.
Specified by:
closein interface AutoCloseable
Throws:
SQLException- SQLException if a database access error occurs
isClosed
boolean isClosed()
throws SQLException
Retrieves whether this Connectionobject has been closed. A connection is closed if the methodclosehas been called on it or if certain fatal errors haveoccurred. This method is guaranteed to return trueonly when it is called after the methodConnection.closehas been called.
This method generally cannot be called to determine whether a connection to a database is valid or invalid. A typical client can determine that a connection isinvalid by catching any exceptions that might be thrown when an operation is attempted.
Returns:
trueif this Connectionobject is closed; falseif it is still open
Throws:
SQLException- if a database access error occurs
getMetaData
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 6 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html#close()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setAutoCommit(boolean)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setAutoCommit(boolean)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setAutoCommit(boolean)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html8/12/2019 Connection (Java Platform Se 7 ) (1)
7/20
DatabaseMetaDatagetMetaData()
throws SQLException
Retrieves aDatabaseMetaDataobject that contains metadata about the database to which this Connectionobject represents a connection. The metadataincludes information about the database's tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, and so on.
Returns:
a DatabaseMetaDataobject for this Connectionobject
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
setReadOnly
void setReadOnly(boolean readOnly)
throws SQLException
Puts this connection in read-only mode as a hint to the driver to enable database optimizations.
Note:This method cannot be called during a transaction.
Parameters:
readOnly-trueenables read-only mode;falsedisables it
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or this method is called during a transaction
isReadOnly
boolean isReadOnly()
throws SQLException
Retrieves whether this Connectionobject is in read-only mode.
Returns:
trueif this Connectionobject is read-only;falseotherwise
Throws:
SQLException- SQLException if a database access error occurs or this method is called on a closed connection
setCatalog
void setCatalog(Stringcatalog)
throws SQLException
Sets the given catalog name in order to select a subspace of this Connectionobject's database in which to work.
If the driver does not support catalogs, it will silently ignore this request.
Calling setCataloghas no effect on previously created or prepared Statementobjects. It is implementation defined whether a DBMS prepare operationtakes place immediately when the Connectionmethod prepareStatementor prepareCallis invoked. For maximum portability,setCatalogshould becalled before a Statementis created or prepared.
Parameters:
catalog- the name of a catalog (subspace in this Connectionobject's database) in which to work
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
See Also:
getCatalog()
getCatalog
StringgetCatalog()
throws SQLException
Retrieves this Connectionobject's current catalog name.
Returns:
the current catalog name or nullif there is none
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
See Also:
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 7 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getCatalog()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html8/12/2019 Connection (Java Platform Se 7 ) (1)
8/20
setCatalog(java.lang.String)
setTransactionIsolation
void setTransactionIsolation(int level)
throws SQLException
Attempts to change the transaction isolation level for this Connectionobject to the one given. The constants defined in the interfaceConnectionare thepossible transaction isolation levels.
Note:If this method is called during a transaction, the result is implementation-defined.
Parameters:
level- one of the following Connectionconstants: Connection.TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_REPEATABLE_READ, orConnection.TRANSACTION_SERIALIZABLE. (Note thatConnection.TRANSACTION_NONEcannotbe used because it specifies that transactions are not supported.)
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameter is not one of the Connectionconstants
See Also:
DatabaseMetaData.supportsTransactionIsolationLevel(int),getTransactionIsolation()
getTransactionIsolation
int getTransactionIsolation()
throws SQLException
Retrieves this Connectionobject's current transaction isolation level.
Returns:
the current transaction isolation level, which will be one of the following constants:Connection.TRANSACTION_READ_UNCOMMITTED,Connection.TRANSACTION_READ_COMMITTED,Connection.TRANSACTION_REPEATABLE_READ,Connection.TRANSACTION_SERIALIZABLE, orConnection.TRANSACTION_NONE.
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
See Also:
setTransactionIsolation(int)
getWarnings
SQLWarninggetWarnings()
throws SQLException
Retrieves the first warning reported by calls on this Connectionobject. If there is more than one warning, subsequent warnings will be chained to the firstone and can be retrieved by calling the method SQLWarning.getNextWarningon the warning that was retrieved previously.
This method may not be called on a closed connection; doing so will cause an SQLExceptionto be thrown.
Note:Subsequent warnings wil l be chained to this SQLWarning.
Returns:
the first SQLWarningobject or nullif there are noneThrows:
SQLException- if a database access error occurs or this method is called on a closed connection
See Also:
SQLWarning
clearWarnings
void clearWarnings()
throws SQLException
Clears all warnings reported for this Connectionobject. After a call to this method, the method getWarningsreturns nulluntil a new warning is reported
for this Connectionobject.Throws:
SQLException- SQLException if a database access error occurs or this method is called on a closed connection
createStatement
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 8 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLWarning.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLWarning.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setTransactionIsolation(int)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getTransactionIsolation()http://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#supportsTransactionIsolationLevel(int)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setCatalog(java.lang.String)8/12/2019 Connection (Java Platform Se 7 ) (1)
9/20
StatementcreateStatement(int resultSetType,
int resultSetConcurrency)
throws SQLException
Creates a Statementobject that will generate ResultSetobjects with the given type and concurrency. This method is the same as the createStatementmethod above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can be determined bycalling getHoldability().
Parameters:
resultSetType- a result set type; one of ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYor ResultSet.CONCUR_UPDATABLE
Returns:
a newStatementobject that will generate ResultSetobjects with the given type and concurrency
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type and concurrency
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set typeand result set concurrency.
Since:
1.2
prepareStatement
PreparedStatementprepareStatement(Stringsql,
int resultSetType,
int resultSetConcurrency) throws SQLException
Creates a PreparedStatementobject that will generate ResultSetobjects with the given type and concurrency. This method is the same as theprepareStatementmethod above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can bedetermined by calling getHoldability().
Parameters:
sql- a Stringobject that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
resultSetType- a result set type; one of ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYor ResultSet.CONCUR_UPDATABLE
Returns:
a new PreparedStatement object containing the pre-compiled SQL statement that will produceResultSetobjects with the given type and concurrency
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type and concurrency
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set typeand result set concurrency.
Since:
1.2
prepareCall
CallableStatementprepareCall(Stringsql,
int resultSetType,
int resultSetConcurrency)
throws SQLException
Creates a CallableStatementobject that will generate ResultSetobjects with the given type and concurrency. This method is the same as theprepareCallmethod above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can bedetermined by calling getHoldability().
Parameters:
sql- a Stringobject that is the SQL statement to be sent to the database; may contain on or more '?' parameters
resultSetType- a result set type; one of ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, or
ResultSet.TYPE_SCROLL_SENSITIVEresultSetConcurrency- a concurrency type; one ofResultSet.CONCUR_READ_ONLYor ResultSet.CONCUR_UPDATABLE
Returns:
a newCallableStatementobject containing the pre-compiled SQL statement that will produceResultSetobjects with the given type and concurrency
Throws:
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 9 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html8/12/2019 Connection (Java Platform Se 7 ) (1)
10/20
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type and concurrency
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set typeand result set concurrency.
Since:
1.2
getTypeMap
Map> myMap = con.getTypeMap();
myMap.put("mySchemaName.ATHLETES", Athletes.class);
con.setTypeMap(myMap);
Returns:
thejava.util.Mapobject associated with this Connectionobject
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.2
See Also:
setTypeMap(java.util.Map> map) throws SQLException
Installs the givenTypeMapobject as the type map for this Connectionobject. The type map will be used for the custom mapping of SQL structured typesand distinct types.
You must set the the values for the TypeMapprior to callng setMapas a JDBC driver may create an internal copy of the TypeMap:
Map myMap>();
myMap.put("mySchemaName.ATHLETES", Athletes.class); con.setTypeMap(myMap);
Parameters:
map- the java.util.Mapobject to install as the replacement for this Connectionobject's default type map
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameter is not a java.util.Mapobject
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.2
See Also:
getTypeMap()
setHoldability
void setHoldability(int holdability)
throws SQLException
Changes the default holdability ofResultSetobjects created using this Connectionobject to the given holdability. The default holdability of ResultSetobjects can be be determined by invoking DatabaseMetaData.getResultSetHoldability().
Parameters:
holdability- aResultSetholdability constant; one of ResultSet.HOLD_CURSORS_OVER_COMMITor ResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
SQLException- if a database access occurs, this method is called on a closed connection, or the given parameter is not aResultSetconstant
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 10 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getResultSetHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getTypeMap()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/Class.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/Map.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setTypeMap(java.util.Map)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/Class.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/Map.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html8/12/2019 Connection (Java Platform Se 7 ) (1)
11/20
indicating holdability
SQLFeatureNotSupportedException- if the given holdability is not supported
Since:
1.4
See Also:
getHoldability(),DatabaseMetaData.getResultSetHoldability(),ResultSet
getHoldability
int getHoldability()
throws SQLException
Retrieves the current holdability ofResultSetobjects created using this Connectionobject.
Returns:
the holdability, one of ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
Since:
1.4
See Also:
setHoldability(int),DatabaseMetaData.getResultSetHoldability(),ResultSet
setSavepoint
SavepointsetSavepoint()
throws SQLException
Creates an unnamed savepoint in the current transaction and returns the new Savepointobject that represents it.
if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly created savepoint.
Returns:
the newSavepointobject
Throws:
SQLException- if a database access error occurs, this method is called while participating in a distributed transaction, this method is called on aclosed connection or this Connectionobject is currently in auto-commit mode
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.4
See Also:
Savepoint
setSavepoint
SavepointsetSavepoint(Stringname)
throws SQLException
Creates a savepoint with the given name in the current transaction and returns the new Savepointobject that represents it.
if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly created savepoint.
Parameters:
name- a Stringcontaining the name of the savepoint
Returns:
the newSavepointobject
Throws:
SQLException- if a database access error occurs, this method is called while participating in a distributed transaction, this method is called on aclosed connection or this Connectionobject is currently in auto-commit mode
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.4
See Also:
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 11 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getResultSetHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setHoldability(int)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getResultSetHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.html8/12/2019 Connection (Java Platform Se 7 ) (1)
12/20
Savepoint
rollback
void rollback(Savepointsavepoint)
throws SQLException
Undoes all changes made after the givenSavepointobject was set.
This method should be used only when auto-commit has been disabled.
Parameters:savepoint- the Savepointobject to roll back to
Throws:
SQLException- if a database access error occurs, this method is called while participating in a distributed transaction, this method is called on aclosed connection, the Savepointobject is no longer valid, or this Connectionobject is currently in auto-commit mode
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.4
See Also:
Savepoint,rollback()
releaseSavepoint
void releaseSavepoint(Savepointsavepoint)
throws SQLException
Removes the specified Savepointand subsequent Savepointobjects from the current transaction. Any reference to the savepoint after it have beenremoved will cause an SQLExceptionto be thrown.
Parameters:
savepoint- the Savepointobject to be removed
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the givenSavepointobject is not a valid savepointin the current transaction
SQLFeatureNotSupportedException- if the JDBC driver does not support this methodSince:
1.4
createStatement
StatementcreateStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) throws SQLException
Creates a Statementobject that will generate ResultSetobjects with the given type, concurrency, and holdability. This method is the same as thecreateStatementmethod above, but it allows the default result set type, concurrency, and holdability to be overridden.
Parameters:
resultSetType- one of the following ResultSetconstants: ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency- one of the following ResultSetconstants: ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE
resultSetHoldability- one of the following ResultSetconstants: ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a newStatementobject that will generate ResultSetobjects with the given type, concurrency, and holdability
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type, concurrency, and holdability
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set type,result set holdability and result set concurrency.
Since:
1.4
See Also:
ResultSet
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 12 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Statement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#rollback()http://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Savepoint.html8/12/2019 Connection (Java Platform Se 7 ) (1)
13/20
prepareStatement
PreparedStatementprepareStatement(Stringsql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
Creates a PreparedStatementobject that will generate ResultSetobjects with the given type, concurrency, and holdability.
This method is the same as the prepareStatementmethod above, but it allows the default result set type, concurrency, and holdability to be overridden.
Parameters:
sql- a Stringobject that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
resultSetType- one of the following ResultSetconstants: ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency- one of the following ResultSetconstants: ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE
resultSetHoldability- one of the following ResultSetconstants: ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a newPreparedStatementobject, containing the pre-compiled SQL statement, that will generate ResultSetobjects with the given type, concurrency,and holdability
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type, concurrency, and holdability
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set type,result set holdability and result set concurrency.
Since:
1.4
See Also:
ResultSet
prepareCall
CallableStatementprepareCall(Stringsql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
Creates a CallableStatementobject that will generate ResultSetobjects with the given type and concurrency. This method is the same as theprepareCallmethod above, but it allows the default result set type, result set concurrency type and holdability to be overridden.
Parameters:
sql- a Stringobject that is the SQL statement to be sent to the database; may contain on or more '?' parameters
resultSetType- one of the following ResultSetconstants: ResultSet.TYPE_FORWARD_ONLY,ResultSet.TYPE_SCROLL_INSENSITIVE, orResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency- one of the following ResultSetconstants: ResultSet.CONCUR_READ_ONLYorResultSet.CONCUR_UPDATABLE
resultSetHoldability- one of the following ResultSetconstants: ResultSet.HOLD_CURSORS_OVER_COMMITorResultSet.CLOSE_CURSORS_AT_COMMIT
Returns:
a newCallableStatementobject, containing the pre-compiled SQL statement, that will generate ResultSetobjects with the given type, concurrency,and holdability
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameters are notResultSetconstantsindicating type, concurrency, and holdability
SQLFeatureNotSupportedException- if the JDBC driver does not support this method or this method is not supported for the specified result set type,result set holdability and result set concurrency.
Since:
1.4
See Also:
ResultSet
prepareStatement
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 13 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/CallableStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/ResultSet.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html8/12/2019 Connection (Java Platform Se 7 ) (1)
14/20
PreparedStatementprepareStatement(Stringsql,
int autoGeneratedKeys)
throws SQLException
Creates a defaultPreparedStatementobject that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it shouldmake auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERTstatement, or an SQL statement able toreturn auto-generated keys (the l ist of such statements is vendor-specific).
Note:This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the methodprepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statementmay not be sent to the database until the PreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methodsthrow certain SQLExceptions.
Result sets created using the returnedPreparedStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level of
CONCUR_READ_ONLY. The holdability of the created result sets can be determined by callinggetHoldability().
Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholders
autoGeneratedKeys- a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYSorStatement.NO_GENERATED_KEYS
Returns:
a newPreparedStatementobject, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection or the given parameter is not a Statementconstantindicating whether auto-generated keys should be returned
SQLFeatureNotSupportedException- if the JDBC driver does not support this method with a constant of Statement.RETURN_GENERATED_KEYS
Since:
1.4
prepareStatement
PreparedStatementprepareStatement(Stringsql,
int[] columnIndexes)
throws SQLException
Creates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array. This array contains the indexes ofthe columns in the target table that contain the auto-generated keys that should be made available. The driver will ignore the array if the SQL statement is notanINSERTstatement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatementobject. This object can then be used to efficiently
execute this statement multiple times.
Note:This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the methodprepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statementmay not be sent to the database until the PreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methodsthrow certain SQLExceptions.
Result sets created using the returnedPreparedStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY. The holdability of the created result sets can be determined by callinggetHoldability().
Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholders
columnIndexes- an array of column indexes indicating the columns that should be returned from the inserted row or rows
Returns:
a newPreparedStatementobject, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given
array of column indexes
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.4
prepareStatement
PreparedStatementprepareStatement(Stringsql,
String[] columnNames)
throws SQLException
Creates a defaultPreparedStatementobject capable of returning the auto-generated keys designated by the given array. This array contains the names ofthe columns in the target table that contain the auto-generated keys that should be returned. The driver will ignore the array if the SQL statement is not anINSERTstatement, or an SQL statement able to return auto-generated keys (the list of such statements is vendor-specific).
An SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatementobject. This object can then be used to efficientlyexecute this statement multiple times.
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 14 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html8/12/2019 Connection (Java Platform Se 7 ) (1)
15/20
Note:This method is optimized for handling parametric SQL statements that benefit from precompilation. If the driver supports precompilation, the methodprepareStatementwill send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statementmay not be sent to the database until the PreparedStatementobject is executed. This has no direct effect on users; however, it does affect which methodsthrow certain SQLExceptions.
Result sets created using the returnedPreparedStatementobject will by default be type TYPE_FORWARD_ONLYand have a concurrency level ofCONCUR_READ_ONLY. The holdability of the created result sets can be determined by callinggetHoldability().
Parameters:
sql- an SQL statement that may contain one or more '?' IN parameter placeholders
columnNames- an array of column names indicating the columns that should be returned from the inserted row or rows
Returns:
a newPreparedStatementobject, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the givenarray of column names
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.4
createClob
ClobcreateClob() throws SQLException
Constructs an object that implements theClobinterface. The object returned initially contains no data. The setAsciiStream,setCharacterStreamandsetStringmethods of theClobinterface may be used to add data to theClob.
Returns:
An object that implements theClobinterface
Throws:
SQLException- if an object that implements the Clobinterface can not be constructed, this method is called on a closed connection or a databaseaccess error occurs.
SQLFeatureNotSupportedException- if the JDBC driver does not support this data type
Since:
1.6
createBlob
BlobcreateBlob()
throws SQLException
Constructs an object that implements theBlobinterface. The object returned initially contains no data. The setBinaryStreamand setBytesmethods oftheBlobinterface may be used to add data to theBlob.
Returns:
An object that implements theBlobinterface
Throws:
SQLException- if an object that implements the Blobinterface can not be constructed, this method is called on a closed connection or a databaseaccess error occurs.
SQLFeatureNotSupportedException- if the JDBC driver does not support this data type
Since:
1.6
createNClob
NClobcreateNClob()
throws SQLException
Constructs an object that implements theNClobinterface. The object returned initially contains no data. The setAsciiStream,setCharacterStreamandsetStringmethods of theNClobinterface may be used to add data to the NClob.
Returns:
An object that implements theNClobinterface
Throws:
SQLException- if an object that implements the NClobinterface can not be constructed, this method is called on a closed connection or a databaseaccess error occurs.
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 15 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/NClob.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Blob.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Clob.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getHoldability()8/12/2019 Connection (Java Platform Se 7 ) (1)
16/20
SQLFeatureNotSupportedException- if the JDBC driver does not support this data type
Since:
1.6
createSQLXML
SQLXMLcreateSQLXML()
throws SQLException
Constructs an object that implements theSQLXMLinterface. The object returned initially contains no data. The createXmlStreamWriterobject andsetStringmethod of the SQLXMLinterface may be used to add data to the SQLXMLobject.
Returns:
An object that implements theSQLXMLinterface
Throws:
SQLException- if an object that implements the SQLXMLinterface can not be constructed, this method is called on a closed connection or a databaseaccess error occurs.
SQLFeatureNotSupportedException- if the JDBC driver does not support this data type
Since:
1.6
isValid
boolean isValid(int timeout)
throws SQLException
Returns true if the connection has not been closed and is still valid. The driver shall submit a query on the connection or use some other mechanism thatpositively verifies the connection is still valid when this method is called.
The query submitted by the driver to validate the connection shall be executed in the context of the current transaction.
Parameters:
timeout- - The time in seconds to wait for the database operation used to validate the connection to complete. If the timeout period expires before theoperation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation.
Returns:
true if the connection is valid, false otherwise
Throws:
SQLException- if the value supplied for timeoutis less then 0
Since:
1.6
See Also:
DatabaseMetaData.getClientInfoProperties()
setClientInfo
void setClientInfo(Stringname,
Stringvalue) throws SQLClientInfoException
Sets the value of the client info property specified by name to the value specified by value.
Applications may use the DatabaseMetaData.getClientInfoPropertiesmethod to determine the client info properties supported by the driver and themaximum length that may be specified for each property.
The driver stores the value specified in a suitable location in the database. For example in a special register, session parameter, or system table column.For efficiency the driver may defer setting the value in the database until the next time a statement is executed or prepared. Other than storing the clientinformation in the appropriate place in the database, these methods shall not alter the behavior of the connection in anyway. The values supplied to thesemethods are used for accounting, diagnostics and debugging purposes only.
The driver shall generate a warning if the client info name specified is not recognized by the driver.
If the value specified to this method is greater than the maximum length for the property the driver may either truncate the value and generate a warning orgenerate aSQLClientInfoException. If the driver generates a SQLClientInfoException, the value specified was not set on the connection.
The following are standard client info properties. Drivers are not required to support these properties however if the driver supports a client info property thatcan be described by one of the standard properties, the standard property name should be used.
ApplicationName - The name of the application currently utilizing the connectionClientUser - The name of the user that the application using the connection is performing work for. This may not be the same as the user name thatwas used in establishing the connection.ClientHostname - The hostname of the computer the application using the connection is running on.
Parameters:
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 16 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLClientInfoException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.html#getClientInfoProperties()http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLXML.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.html8/12/2019 Connection (Java Platform Se 7 ) (1)
17/20
8/12/2019 Connection (Java Platform Se 7 ) (1)
18/20
connection
Since:
1.6
createArrayOf
ArraycreateArrayOf(StringtypeName,
Object[] elements) throws SQLException
Factory method for creating Array objects.
Note:WhencreateArrayOfis used to create an array object that maps to a primitive data type, then it is implementation-defined whether theArrayobjectis an array of that primitive data type or an array of Object.
Note:The JDBC driver is responsible for mapping the elements Objectarray to the default JDBC SQL type defined in java.sql.Types for the given class ofObject. The default mapping is specified in Appendix B of the JDBC specification. If the resulting JDBC type is not the appropriate type for the giventypeName then it is implementation defined whether an SQLExceptionis thrown or the driver supports the resulting conversion.
Parameters:
typeName- the SQL name of the type the elements of the array map to. The typeName is a database-specific name which may be the name of a built-intype, a user-defined type or a standard SQL type supported by this database. This is the value returned by Array.getBaseTypeName
elements- the elements that populate the returned object
Returns:
an Array object whose elements map to the specified SQL typeThrows:
SQLException- if a database error occurs, the JDBC type is not appropriate for the typeName and the conversion is not supported, the typeName is nullor this method is called on a closed connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this data type
Since:
1.6
createStruct
StructcreateStruct(StringtypeName,
Object[] attributes)
throws SQLException
Factory method for creating Struct objects.
Parameters:
typeName- the SQL type name of the SQL structured type that this Structobject maps to. The typeName is the name of a user-defined type that hasbeen defined for this database. It is the value returned by Struct.getSQLTypeName.
attributes- the attributes that populate the returned object
Returns:
a Struct object that maps to the given SQL type and is populated with the given attributes
Throws:
SQLException- if a database error occurs, the typeName is null or this method is called on a closed connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this data typeSince:
1.6
setSchema
void setSchema(Stringschema)
throws SQLException
Sets the given schema name to access.
If the driver does not support schemas, it will silently ignore this request.
Calling setSchemahas no effect on previously created or prepared Statementobjects. It is implementation defined whether a DBMS prepare operation
takes place immediately when the Connectionmethod prepareStatementor prepareCallis invoked. For maximum portability,setSchemashould becalled before a Statementis created or prepared.
Parameters:
schema- the name of a schema in which to work
Throws:
S LExce tion- if a database access error occurs or this method is called on a closed connection
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 18 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/Object.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Struct.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/Object.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Array.html8/12/2019 Connection (Java Platform Se 7 ) (1)
19/20
Since:
1.7
See Also:
getSchema()
getSchema
StringgetSchema()
throws SQLException
Retrieves this Connectionobject's current schema name.
Returns:
the current schema name or nullif there is none
Throws:
SQLException- if a database access error occurs or this method is called on a closed connection
Since:
1.7
See Also:
setSchema(java.lang.String)
abort
void abort(Executorexecutor)
throws SQLException
Terminates an open connection. Calling abortresults in:The connection marked as closedCloses any physical connection to the databaseReleases resources used by the connectionInsures that any thread that is currently accessing the connection will either progress to completion or throw an SQLException.
Calling abortmarks the connection closed and releases any resources. Calling aborton a closed connection is a no-op.
It is possible that the aborting and releasing of the resources that are held by the connection can take an extended period of time. When the abortmethodreturns, the connection will have been marked as closed and theExecutorthat was passed as a parameter to abort may still be executing tasks to release
resources.
This method checks to see that there is an SQLPermissionobject before allowing the method to proceed. If a SecurityManagerexists and itscheckPermissionmethod denies calling abort, this method throws a java.lang.SecurityException.
Parameters:
executor- TheExecutorimplementation which will be used byabort.
Throws:
SQLException- if a database access error occurs or the executorisnull,
SecurityException- if a security manager exists and its checkPermissionmethod denies calling abort
Since:
1.7
See Also:
SecurityManager.checkPermission(java.security.Permission),Executor
setNetworkTimeout
void setNetworkTimeout(Executorexecutor,
int milliseconds)
throws SQLException
Sets the maximum period a Connectionor objects created from the Connectionwill wait for the database to reply to any one request. If any requestremains unanswered, the waiting method will return with aSQLException, and the Connectionor objects created from theConnectionwill be marked asclosed. Any subsequent use of the objects, with the exception of the close,isClosedorConnection.isValidmethods, will result in a SQLException.
Note: This method is intended to address a rare but serious condition where network partitions can cause threads issuing JDBC calls to hanguninterruptedly in socket reads, until the OS TCP-TIMEOUT (typically 10 minutes). This method is related to the abort() method which provides an
administrator thread a means to free any such threads in cases where the JDBC connection is accessible to the administrator thread. ThesetNetworkTimeoutmethod will cover cases where there is no administrator thread, or it has no access to the connection. This method is severe in it'seffects, and should be given a high enough value so it is never triggered before any more normal timeouts, such as transaction timeouts.
JDBC driver implementations may also choose to support the setNetworkTimeoutmethod to impose a limit on database response time, in environmentswhere no network is present.
Drivers may internally implement some or all of their API calls with multiple internal driver-database transmissions, and it is left to the driver implementationto determine whether the limit will be a lied alwa s to the res onse to the API call, or to an sin le re uest made durin the API call.
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html 19 / 20
http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#abort(java.util.concurrent.Executor)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/SecurityManager.html#checkPermission(java.security.Permission)http://docs.oracle.com/javase/7/docs/api/java/lang/SecurityException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setSchema(java.lang.String)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/String.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getSchema()8/12/2019 Connection (Java Platform Se 7 ) (1)
20/20
Overview Package Class Use Tree Deprecated Index HelpJava Platform
Standard Ed. 7
Prev Class Next Class Frames No Frames All Classes
Summary: Nested |Field| Constr | Method Detail:Field| Constr | Method
Submit a bug or featureFor further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeteddescriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.Copyright 1993, 2013, Oracle and/or its affiliates. All rights reserved.
This method can be invoked more than once, such as to set a limit for an area of JDBC code, and to reset to the default on exit from this area. Invocation ofthis method has no impact on already outstanding requests.
The Statement.setQueryTimeout()timeout value is independent of the timeout value specified in setNetworkTimeout. If the query timeout expiresbefore the network timeout then the statement execution will be canceled. If the network is still active the result will be that both the statement and connectionare still usable. However if the network timeout expires before the query timeout or if the statement timeout fails due to network problems, the connection willbe marked as closed, any resources held by the connection will be released and both the connection and statement will be unusable.
When the driver determines that the setNetworkTimeouttimeout value has expired, the JDBC driver marks the connection closed and releases anyresources held by the connection.
This method checks to see that there is an SQLPermissionobject before allowing the method to proceed. If a SecurityManagerexists and itscheckPermissionmethod denies calling setNetworkTimeout, this method throws a java.lang.SecurityException.
Parameters:
executor- TheExecutorimplementation which will be used bysetNetworkTimeout.
milliseconds- The time in milliseconds to wait for the database operation to complete. If the JDBC driver does not support milliseconds, the JDBCdriver will round the value up to the nearest second. If the timeout period expires before the operation completes, a SQLException will be thrown. A valueof 0 indicates that there is not timeout for database operations.
Throws:
SQLException- if a database access error occurs, this method is called on a closed connection, theexecutorisnull, or the value specified forsecondsis less than 0.
SecurityException- if a security manager exists and its checkPermissionmethod denies calling setNetworkTimeout.
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.7
See Also:
SecurityManager.checkPermission(java.security.Permission),Statement.setQueryTimeout(int),getNetworkTimeout(),abort(java.util.concurrent.Executor),Executor
getNetworkTimeout
int getNetworkTimeout()
throws SQLException
Retrieves the number of milliseconds the driver will wait for a database request to complete. If the limit is exceeded, aSQLExceptionis thrown.
Returns:
the current timeout limit in milliseconds; zero means there is no limit
Throws:
SQLException- if a database access error occurs or this method is called on a closed Connection
SQLFeatureNotSupportedException- if the JDBC driver does not support this method
Since:
1.7
See Also:
setNetworkTimeout(java.util.concurrent.Executor, int)
Connection (Java Platform SE 7 ) 19/02/2014
http://docs.oracle.com/javase/7/docs/legal/cpyr.htmlhttp://docs.oracle.com/javase/7/docs/index.htmlhttp://bugreport.sun.com/bugreport/http://docs.oracle.com/javase/7/docs/api/allclasses-noframe.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/index.html?java/sql/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/DatabaseMetaData.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Clob.htmlhttp://docs.oracle.com/javase/7/docs/api/help-doc.htmlhttp://docs.oracle.com/javase/7/docs/api/index-files/index-1.htmlhttp://docs.oracle.com/javase/7/docs/api/deprecated-list.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/package-tree.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/class-use/Connection.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/package-summary.htmlhttp://docs.oracle.com/javase/7/docs/api/overview-summary.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#setNetworkTimeout(java.util.concurrent.Executor,%20int)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executor.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#abort(java.util.concurrent.Executor)http://docs.oracle.com/javase/7/docs/api/java/sql/Connection.html#getNetworkTimeout()http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#setQueryTimeout(int)http://docs.oracle.com/javase/7/docs/api/java/lang/SecurityManager.html#checkPermission(java.security.Permission)http://docs.oracle.com/javase/7/docs/api/java/sql/SQLFeatureNotSupportedException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/lang/SecurityException.htmlhttp://docs.oracle.com/javase/7/docs/api/java/sql/SQLException.html