Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/sql/Connection.java
38829 views
/*1* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.sql;2627import java.util.Properties;28import java.util.concurrent.Executor;2930/**31* <P>A connection (session) with a specific32* database. SQL statements are executed and results are returned33* within the context of a connection.34* <P>35* A <code>Connection</code> object's database is able to provide information36* describing its tables, its supported SQL grammar, its stored37* procedures, the capabilities of this connection, and so on. This38* information is obtained with the <code>getMetaData</code> method.39*40* <P><B>Note:</B> When configuring a <code>Connection</code>, JDBC applications41* should use the appropriate <code>Connection</code> method such as42* <code>setAutoCommit</code> or <code>setTransactionIsolation</code>.43* Applications should not invoke SQL commands directly to change the connection's44* configuration when there is a JDBC method available. By default a <code>Connection</code> object is in45* auto-commit mode, which means that it automatically commits changes46* after executing each statement. If auto-commit mode has been47* disabled, the method <code>commit</code> must be called explicitly in48* order to commit changes; otherwise, database changes will not be saved.49* <P>50* A new <code>Connection</code> object created using the JDBC 2.1 core API51* has an initially empty type map associated with it. A user may enter a52* custom mapping for a UDT in this type map.53* When a UDT is retrieved from a data source with the54* method <code>ResultSet.getObject</code>, the <code>getObject</code> method55* will check the connection's type map to see if there is an entry for that56* UDT. If so, the <code>getObject</code> method will map the UDT to the57* class indicated. If there is no entry, the UDT will be mapped using the58* standard mapping.59* <p>60* A user may create a new type map, which is a <code>java.util.Map</code>61* object, make an entry in it, and pass it to the <code>java.sql</code>62* methods that can perform custom mapping. In this case, the method63* will use the given type map instead of the one associated with64* the connection.65* <p>66* For example, the following code fragment specifies that the SQL67* type <code>ATHLETES</code> will be mapped to the class68* <code>Athletes</code> in the Java programming language.69* The code fragment retrieves the type map for the <code>Connection70* </code> object <code>con</code>, inserts the entry into it, and then sets71* the type map with the new entry as the connection's type map.72* <pre>73* java.util.Map map = con.getTypeMap();74* map.put("mySchemaName.ATHLETES", Class.forName("Athletes"));75* con.setTypeMap(map);76* </pre>77*78* @see DriverManager#getConnection79* @see Statement80* @see ResultSet81* @see DatabaseMetaData82*/83public interface Connection extends Wrapper, AutoCloseable {8485/**86* Creates a <code>Statement</code> object for sending87* SQL statements to the database.88* SQL statements without parameters are normally89* executed using <code>Statement</code> objects. If the same SQL statement90* is executed many times, it may be more efficient to use a91* <code>PreparedStatement</code> object.92* <P>93* Result sets created using the returned <code>Statement</code>94* object will by default be type <code>TYPE_FORWARD_ONLY</code>95* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.96* The holdability of the created result sets can be determined by97* calling {@link #getHoldability}.98*99* @return a new default <code>Statement</code> object100* @exception SQLException if a database access error occurs101* or this method is called on a closed connection102*/103Statement createStatement() throws SQLException;104105/**106* Creates a <code>PreparedStatement</code> object for sending107* parameterized SQL statements to the database.108* <P>109* A SQL statement with or without IN parameters can be110* pre-compiled and stored in a <code>PreparedStatement</code> object. This111* object can then be used to efficiently execute this statement112* multiple times.113*114* <P><B>Note:</B> This method is optimized for handling115* parametric SQL statements that benefit from precompilation. If116* the driver supports precompilation,117* the method <code>prepareStatement</code> will send118* the statement to the database for precompilation. Some drivers119* may not support precompilation. In this case, the statement may120* not be sent to the database until the <code>PreparedStatement</code>121* object is executed. This has no direct effect on users; however, it does122* affect which methods throw certain <code>SQLException</code> objects.123* <P>124* Result sets created using the returned <code>PreparedStatement</code>125* object will by default be type <code>TYPE_FORWARD_ONLY</code>126* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.127* The holdability of the created result sets can be determined by128* calling {@link #getHoldability}.129*130* @param sql an SQL statement that may contain one or more '?' IN131* parameter placeholders132* @return a new default <code>PreparedStatement</code> object containing the133* pre-compiled SQL statement134* @exception SQLException if a database access error occurs135* or this method is called on a closed connection136*/137PreparedStatement prepareStatement(String sql)138throws SQLException;139140/**141* Creates a <code>CallableStatement</code> object for calling142* database stored procedures.143* The <code>CallableStatement</code> object provides144* methods for setting up its IN and OUT parameters, and145* methods for executing the call to a stored procedure.146*147* <P><B>Note:</B> This method is optimized for handling stored148* procedure call statements. Some drivers may send the call149* statement to the database when the method <code>prepareCall</code>150* is done; others151* may wait until the <code>CallableStatement</code> object152* is executed. This has no153* direct effect on users; however, it does affect which method154* throws certain SQLExceptions.155* <P>156* Result sets created using the returned <code>CallableStatement</code>157* object will by default be type <code>TYPE_FORWARD_ONLY</code>158* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.159* The holdability of the created result sets can be determined by160* calling {@link #getHoldability}.161*162* @param sql an SQL statement that may contain one or more '?'163* parameter placeholders. Typically this statement is specified using JDBC164* call escape syntax.165* @return a new default <code>CallableStatement</code> object containing the166* pre-compiled SQL statement167* @exception SQLException if a database access error occurs168* or this method is called on a closed connection169*/170CallableStatement prepareCall(String sql) throws SQLException;171172/**173* Converts the given SQL statement into the system's native SQL grammar.174* A driver may convert the JDBC SQL grammar into its system's175* native SQL grammar prior to sending it. This method returns the176* native form of the statement that the driver would have sent.177*178* @param sql an SQL statement that may contain one or more '?'179* parameter placeholders180* @return the native form of this statement181* @exception SQLException if a database access error occurs182* or this method is called on a closed connection183*/184String nativeSQL(String sql) throws SQLException;185186/**187* Sets this connection's auto-commit mode to the given state.188* If a connection is in auto-commit mode, then all its SQL189* statements will be executed and committed as individual190* transactions. Otherwise, its SQL statements are grouped into191* transactions that are terminated by a call to either192* the method <code>commit</code> or the method <code>rollback</code>.193* By default, new connections are in auto-commit194* mode.195* <P>196* The commit occurs when the statement completes. The time when the statement197* completes depends on the type of SQL Statement:198* <ul>199* <li>For DML statements, such as Insert, Update or Delete, and DDL statements,200* the statement is complete as soon as it has finished executing.201* <li>For Select statements, the statement is complete when the associated result202* set is closed.203* <li>For <code>CallableStatement</code> objects or for statements that return204* multiple results, the statement is complete205* when all of the associated result sets have been closed, and all update206* counts and output parameters have been retrieved.207*</ul>208* <P>209* <B>NOTE:</B> If this method is called during a transaction and the210* auto-commit mode is changed, the transaction is committed. If211* <code>setAutoCommit</code> is called and the auto-commit mode is212* not changed, the call is a no-op.213*214* @param autoCommit <code>true</code> to enable auto-commit mode;215* <code>false</code> to disable it216* @exception SQLException if a database access error occurs,217* setAutoCommit(true) is called while participating in a distributed transaction,218* or this method is called on a closed connection219* @see #getAutoCommit220*/221void setAutoCommit(boolean autoCommit) throws SQLException;222223/**224* Retrieves the current auto-commit mode for this <code>Connection</code>225* object.226*227* @return the current state of this <code>Connection</code> object's228* auto-commit mode229* @exception SQLException if a database access error occurs230* or this method is called on a closed connection231* @see #setAutoCommit232*/233boolean getAutoCommit() throws SQLException;234235/**236* Makes all changes made since the previous237* commit/rollback permanent and releases any database locks238* currently held by this <code>Connection</code> object.239* This method should be240* used only when auto-commit mode has been disabled.241*242* @exception SQLException if a database access error occurs,243* this method is called while participating in a distributed transaction,244* if this method is called on a closed connection or this245* <code>Connection</code> object is in auto-commit mode246* @see #setAutoCommit247*/248void commit() throws SQLException;249250/**251* Undoes all changes made in the current transaction252* and releases any database locks currently held253* by this <code>Connection</code> object. This method should be254* used only when auto-commit mode has been disabled.255*256* @exception SQLException if a database access error occurs,257* this method is called while participating in a distributed transaction,258* this method is called on a closed connection or this259* <code>Connection</code> object is in auto-commit mode260* @see #setAutoCommit261*/262void rollback() throws SQLException;263264/**265* Releases this <code>Connection</code> object's database and JDBC resources266* immediately instead of waiting for them to be automatically released.267* <P>268* Calling the method <code>close</code> on a <code>Connection</code>269* object that is already closed is a no-op.270* <P>271* It is <b>strongly recommended</b> that an application explicitly272* commits or rolls back an active transaction prior to calling the273* <code>close</code> method. If the <code>close</code> method is called274* and there is an active transaction, the results are implementation-defined.275* <P>276*277* @exception SQLException SQLException if a database access error occurs278*/279void close() throws SQLException;280281/**282* Retrieves whether this <code>Connection</code> object has been283* closed. A connection is closed if the method <code>close</code>284* has been called on it or if certain fatal errors have occurred.285* This method is guaranteed to return <code>true</code> only when286* it is called after the method <code>Connection.close</code> has287* been called.288* <P>289* This method generally cannot be called to determine whether a290* connection to a database is valid or invalid. A typical client291* can determine that a connection is invalid by catching any292* exceptions that might be thrown when an operation is attempted.293*294* @return <code>true</code> if this <code>Connection</code> object295* is closed; <code>false</code> if it is still open296* @exception SQLException if a database access error occurs297*/298boolean isClosed() throws SQLException;299300//======================================================================301// Advanced features:302303/**304* Retrieves a <code>DatabaseMetaData</code> object that contains305* metadata about the database to which this306* <code>Connection</code> object represents a connection.307* The metadata includes information about the database's308* tables, its supported SQL grammar, its stored309* procedures, the capabilities of this connection, and so on.310*311* @return a <code>DatabaseMetaData</code> object for this312* <code>Connection</code> object313* @exception SQLException if a database access error occurs314* or this method is called on a closed connection315*/316DatabaseMetaData getMetaData() throws SQLException;317318/**319* Puts this connection in read-only mode as a hint to the driver to enable320* database optimizations.321*322* <P><B>Note:</B> This method cannot be called during a transaction.323*324* @param readOnly <code>true</code> enables read-only mode;325* <code>false</code> disables it326* @exception SQLException if a database access error occurs, this327* method is called on a closed connection or this328* method is called during a transaction329*/330void setReadOnly(boolean readOnly) throws SQLException;331332/**333* Retrieves whether this <code>Connection</code>334* object is in read-only mode.335*336* @return <code>true</code> if this <code>Connection</code> object337* is read-only; <code>false</code> otherwise338* @exception SQLException SQLException if a database access error occurs339* or this method is called on a closed connection340*/341boolean isReadOnly() throws SQLException;342343/**344* Sets the given catalog name in order to select345* a subspace of this <code>Connection</code> object's database346* in which to work.347* <P>348* If the driver does not support catalogs, it will349* silently ignore this request.350* <p>351* Calling {@code setCatalog} has no effect on previously created or prepared352* {@code Statement} objects. It is implementation defined whether a DBMS353* prepare operation takes place immediately when the {@code Connection}354* method {@code prepareStatement} or {@code prepareCall} is invoked.355* For maximum portability, {@code setCatalog} should be called before a356* {@code Statement} is created or prepared.357*358* @param catalog the name of a catalog (subspace in this359* <code>Connection</code> object's database) in which to work360* @exception SQLException if a database access error occurs361* or this method is called on a closed connection362* @see #getCatalog363*/364void setCatalog(String catalog) throws SQLException;365366/**367* Retrieves this <code>Connection</code> object's current catalog name.368*369* @return the current catalog name or <code>null</code> if there is none370* @exception SQLException if a database access error occurs371* or this method is called on a closed connection372* @see #setCatalog373*/374String getCatalog() throws SQLException;375376/**377* A constant indicating that transactions are not supported.378*/379int TRANSACTION_NONE = 0;380381/**382* A constant indicating that383* dirty reads, non-repeatable reads and phantom reads can occur.384* This level allows a row changed by one transaction to be read385* by another transaction before any changes in that row have been386* committed (a "dirty read"). If any of the changes are rolled back,387* the second transaction will have retrieved an invalid row.388*/389int TRANSACTION_READ_UNCOMMITTED = 1;390391/**392* A constant indicating that393* dirty reads are prevented; non-repeatable reads and phantom394* reads can occur. This level only prohibits a transaction395* from reading a row with uncommitted changes in it.396*/397int TRANSACTION_READ_COMMITTED = 2;398399/**400* A constant indicating that401* dirty reads and non-repeatable reads are prevented; phantom402* reads can occur. This level prohibits a transaction from403* reading a row with uncommitted changes in it, and it also404* prohibits the situation where one transaction reads a row,405* a second transaction alters the row, and the first transaction406* rereads the row, getting different values the second time407* (a "non-repeatable read").408*/409int TRANSACTION_REPEATABLE_READ = 4;410411/**412* A constant indicating that413* dirty reads, non-repeatable reads and phantom reads are prevented.414* This level includes the prohibitions in415* <code>TRANSACTION_REPEATABLE_READ</code> and further prohibits the416* situation where one transaction reads all rows that satisfy417* a <code>WHERE</code> condition, a second transaction inserts a row that418* satisfies that <code>WHERE</code> condition, and the first transaction419* rereads for the same condition, retrieving the additional420* "phantom" row in the second read.421*/422int TRANSACTION_SERIALIZABLE = 8;423424/**425* Attempts to change the transaction isolation level for this426* <code>Connection</code> object to the one given.427* The constants defined in the interface <code>Connection</code>428* are the possible transaction isolation levels.429* <P>430* <B>Note:</B> If this method is called during a transaction, the result431* is implementation-defined.432*433* @param level one of the following <code>Connection</code> constants:434* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,435* <code>Connection.TRANSACTION_READ_COMMITTED</code>,436* <code>Connection.TRANSACTION_REPEATABLE_READ</code>, or437* <code>Connection.TRANSACTION_SERIALIZABLE</code>.438* (Note that <code>Connection.TRANSACTION_NONE</code> cannot be used439* because it specifies that transactions are not supported.)440* @exception SQLException if a database access error occurs, this441* method is called on a closed connection442* or the given parameter is not one of the <code>Connection</code>443* constants444* @see DatabaseMetaData#supportsTransactionIsolationLevel445* @see #getTransactionIsolation446*/447void setTransactionIsolation(int level) throws SQLException;448449/**450* Retrieves this <code>Connection</code> object's current451* transaction isolation level.452*453* @return the current transaction isolation level, which will be one454* of the following constants:455* <code>Connection.TRANSACTION_READ_UNCOMMITTED</code>,456* <code>Connection.TRANSACTION_READ_COMMITTED</code>,457* <code>Connection.TRANSACTION_REPEATABLE_READ</code>,458* <code>Connection.TRANSACTION_SERIALIZABLE</code>, or459* <code>Connection.TRANSACTION_NONE</code>.460* @exception SQLException if a database access error occurs461* or this method is called on a closed connection462* @see #setTransactionIsolation463*/464int getTransactionIsolation() throws SQLException;465466/**467* Retrieves the first warning reported by calls on this468* <code>Connection</code> object. If there is more than one469* warning, subsequent warnings will be chained to the first one470* and can be retrieved by calling the method471* <code>SQLWarning.getNextWarning</code> on the warning472* that was retrieved previously.473* <P>474* This method may not be475* called on a closed connection; doing so will cause an476* <code>SQLException</code> to be thrown.477*478* <P><B>Note:</B> Subsequent warnings will be chained to this479* SQLWarning.480*481* @return the first <code>SQLWarning</code> object or <code>null</code>482* if there are none483* @exception SQLException if a database access error occurs or484* this method is called on a closed connection485* @see SQLWarning486*/487SQLWarning getWarnings() throws SQLException;488489/**490* Clears all warnings reported for this <code>Connection</code> object.491* After a call to this method, the method <code>getWarnings</code>492* returns <code>null</code> until a new warning is493* reported for this <code>Connection</code> object.494*495* @exception SQLException SQLException if a database access error occurs496* or this method is called on a closed connection497*/498void clearWarnings() throws SQLException;499500501//--------------------------JDBC 2.0-----------------------------502503/**504* Creates a <code>Statement</code> object that will generate505* <code>ResultSet</code> objects with the given type and concurrency.506* This method is the same as the <code>createStatement</code> method507* above, but it allows the default result set508* type and concurrency to be overridden.509* The holdability of the created result sets can be determined by510* calling {@link #getHoldability}.511*512* @param resultSetType a result set type; one of513* <code>ResultSet.TYPE_FORWARD_ONLY</code>,514* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or515* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>516* @param resultSetConcurrency a concurrency type; one of517* <code>ResultSet.CONCUR_READ_ONLY</code> or518* <code>ResultSet.CONCUR_UPDATABLE</code>519* @return a new <code>Statement</code> object that will generate520* <code>ResultSet</code> objects with the given type and521* concurrency522* @exception SQLException if a database access error occurs, this523* method is called on a closed connection524* or the given parameters are not <code>ResultSet</code>525* constants indicating type and concurrency526* @exception SQLFeatureNotSupportedException if the JDBC driver does not support527* this method or this method is not supported for the specified result528* set type and result set concurrency.529* @since 1.2530*/531Statement createStatement(int resultSetType, int resultSetConcurrency)532throws SQLException;533534/**535*536* Creates a <code>PreparedStatement</code> object that will generate537* <code>ResultSet</code> objects with the given type and concurrency.538* This method is the same as the <code>prepareStatement</code> method539* above, but it allows the default result set540* type and concurrency to be overridden.541* The holdability of the created result sets can be determined by542* calling {@link #getHoldability}.543*544* @param sql a <code>String</code> object that is the SQL statement to545* be sent to the database; may contain one or more '?' IN546* parameters547* @param resultSetType a result set type; one of548* <code>ResultSet.TYPE_FORWARD_ONLY</code>,549* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or550* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>551* @param resultSetConcurrency a concurrency type; one of552* <code>ResultSet.CONCUR_READ_ONLY</code> or553* <code>ResultSet.CONCUR_UPDATABLE</code>554* @return a new PreparedStatement object containing the555* pre-compiled SQL statement that will produce <code>ResultSet</code>556* objects with the given type and concurrency557* @exception SQLException if a database access error occurs, this558* method is called on a closed connection559* or the given parameters are not <code>ResultSet</code>560* constants indicating type and concurrency561* @exception SQLFeatureNotSupportedException if the JDBC driver does not support562* this method or this method is not supported for the specified result563* set type and result set concurrency.564* @since 1.2565*/566PreparedStatement prepareStatement(String sql, int resultSetType,567int resultSetConcurrency)568throws SQLException;569570/**571* Creates a <code>CallableStatement</code> object that will generate572* <code>ResultSet</code> objects with the given type and concurrency.573* This method is the same as the <code>prepareCall</code> method574* above, but it allows the default result set575* type and concurrency to be overridden.576* The holdability of the created result sets can be determined by577* calling {@link #getHoldability}.578*579* @param sql a <code>String</code> object that is the SQL statement to580* be sent to the database; may contain on or more '?' parameters581* @param resultSetType a result set type; one of582* <code>ResultSet.TYPE_FORWARD_ONLY</code>,583* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or584* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>585* @param resultSetConcurrency a concurrency type; one of586* <code>ResultSet.CONCUR_READ_ONLY</code> or587* <code>ResultSet.CONCUR_UPDATABLE</code>588* @return a new <code>CallableStatement</code> object containing the589* pre-compiled SQL statement that will produce <code>ResultSet</code>590* objects with the given type and concurrency591* @exception SQLException if a database access error occurs, this method592* is called on a closed connection593* or the given parameters are not <code>ResultSet</code>594* constants indicating type and concurrency595* @exception SQLFeatureNotSupportedException if the JDBC driver does not support596* this method or this method is not supported for the specified result597* set type and result set concurrency.598* @since 1.2599*/600CallableStatement prepareCall(String sql, int resultSetType,601int resultSetConcurrency) throws SQLException;602603/**604* Retrieves the <code>Map</code> object associated with this605* <code>Connection</code> object.606* Unless the application has added an entry, the type map returned607* will be empty.608* <p>609* You must invoke <code>setTypeMap</code> after making changes to the610* <code>Map</code> object returned from611* <code>getTypeMap</code> as a JDBC driver may create an internal612* copy of the <code>Map</code> object passed to <code>setTypeMap</code>:613*614* <pre>615* Map<String,Class<?>> myMap = con.getTypeMap();616* myMap.put("mySchemaName.ATHLETES", Athletes.class);617* con.setTypeMap(myMap);618* </pre>619* @return the <code>java.util.Map</code> object associated620* with this <code>Connection</code> object621* @exception SQLException if a database access error occurs622* or this method is called on a closed connection623* @exception SQLFeatureNotSupportedException if the JDBC driver does not support624* this method625* @since 1.2626* @see #setTypeMap627*/628java.util.Map<String,Class<?>> getTypeMap() throws SQLException;629630/**631* Installs the given <code>TypeMap</code> object as the type map for632* this <code>Connection</code> object. The type map will be used for the633* custom mapping of SQL structured types and distinct types.634*<p>635* You must set the the values for the <code>TypeMap</code> prior to636* callng <code>setMap</code> as a JDBC driver may create an internal copy637* of the <code>TypeMap</code>:638*639* <pre>640* Map myMap<String,Class<?>> = new HashMap<String,Class<?>>();641* myMap.put("mySchemaName.ATHLETES", Athletes.class);642* con.setTypeMap(myMap);643* </pre>644* @param map the <code>java.util.Map</code> object to install645* as the replacement for this <code>Connection</code>646* object's default type map647* @exception SQLException if a database access error occurs, this648* method is called on a closed connection or649* the given parameter is not a <code>java.util.Map</code>650* object651* @exception SQLFeatureNotSupportedException if the JDBC driver does not support652* this method653* @since 1.2654* @see #getTypeMap655*/656void setTypeMap(java.util.Map<String,Class<?>> map) throws SQLException;657658//--------------------------JDBC 3.0-----------------------------659660661/**662* Changes the default holdability of <code>ResultSet</code> objects663* created using this <code>Connection</code> object to the given664* holdability. The default holdability of <code>ResultSet</code> objects665* can be be determined by invoking666* {@link DatabaseMetaData#getResultSetHoldability}.667*668* @param holdability a <code>ResultSet</code> holdability constant; one of669* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or670* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>671* @throws SQLException if a database access occurs, this method is called672* on a closed connection, or the given parameter673* is not a <code>ResultSet</code> constant indicating holdability674* @exception SQLFeatureNotSupportedException if the given holdability is not supported675* @see #getHoldability676* @see DatabaseMetaData#getResultSetHoldability677* @see ResultSet678* @since 1.4679*/680void setHoldability(int holdability) throws SQLException;681682/**683* Retrieves the current holdability of <code>ResultSet</code> objects684* created using this <code>Connection</code> object.685*686* @return the holdability, one of687* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or688* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>689* @throws SQLException if a database access error occurs690* or this method is called on a closed connection691* @see #setHoldability692* @see DatabaseMetaData#getResultSetHoldability693* @see ResultSet694* @since 1.4695*/696int getHoldability() throws SQLException;697698/**699* Creates an unnamed savepoint in the current transaction and700* returns the new <code>Savepoint</code> object that represents it.701*702*<p> if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly created703*savepoint.704*705* @return the new <code>Savepoint</code> object706* @exception SQLException if a database access error occurs,707* this method is called while participating in a distributed transaction,708* this method is called on a closed connection709* or this <code>Connection</code> object is currently in710* auto-commit mode711* @exception SQLFeatureNotSupportedException if the JDBC driver does not support712* this method713* @see Savepoint714* @since 1.4715*/716Savepoint setSavepoint() throws SQLException;717718/**719* Creates a savepoint with the given name in the current transaction720* and returns the new <code>Savepoint</code> object that represents it.721*722* <p> if setSavepoint is invoked outside of an active transaction, a transaction will be started at this newly created723*savepoint.724*725* @param name a <code>String</code> containing the name of the savepoint726* @return the new <code>Savepoint</code> object727* @exception SQLException if a database access error occurs,728* this method is called while participating in a distributed transaction,729* this method is called on a closed connection730* or this <code>Connection</code> object is currently in731* auto-commit mode732* @exception SQLFeatureNotSupportedException if the JDBC driver does not support733* this method734* @see Savepoint735* @since 1.4736*/737Savepoint setSavepoint(String name) throws SQLException;738739/**740* Undoes all changes made after the given <code>Savepoint</code> object741* was set.742* <P>743* This method should be used only when auto-commit has been disabled.744*745* @param savepoint the <code>Savepoint</code> object to roll back to746* @exception SQLException if a database access error occurs,747* this method is called while participating in a distributed transaction,748* this method is called on a closed connection,749* the <code>Savepoint</code> object is no longer valid,750* or this <code>Connection</code> object is currently in751* auto-commit mode752* @exception SQLFeatureNotSupportedException if the JDBC driver does not support753* this method754* @see Savepoint755* @see #rollback756* @since 1.4757*/758void rollback(Savepoint savepoint) throws SQLException;759760/**761* Removes the specified <code>Savepoint</code> and subsequent <code>Savepoint</code> objects from the current762* transaction. Any reference to the savepoint after it have been removed763* will cause an <code>SQLException</code> to be thrown.764*765* @param savepoint the <code>Savepoint</code> object to be removed766* @exception SQLException if a database access error occurs, this767* method is called on a closed connection or768* the given <code>Savepoint</code> object is not a valid769* savepoint in the current transaction770* @exception SQLFeatureNotSupportedException if the JDBC driver does not support771* this method772* @since 1.4773*/774void releaseSavepoint(Savepoint savepoint) throws SQLException;775776/**777* Creates a <code>Statement</code> object that will generate778* <code>ResultSet</code> objects with the given type, concurrency,779* and holdability.780* This method is the same as the <code>createStatement</code> method781* above, but it allows the default result set782* type, concurrency, and holdability to be overridden.783*784* @param resultSetType one of the following <code>ResultSet</code>785* constants:786* <code>ResultSet.TYPE_FORWARD_ONLY</code>,787* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or788* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>789* @param resultSetConcurrency one of the following <code>ResultSet</code>790* constants:791* <code>ResultSet.CONCUR_READ_ONLY</code> or792* <code>ResultSet.CONCUR_UPDATABLE</code>793* @param resultSetHoldability one of the following <code>ResultSet</code>794* constants:795* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or796* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>797* @return a new <code>Statement</code> object that will generate798* <code>ResultSet</code> objects with the given type,799* concurrency, and holdability800* @exception SQLException if a database access error occurs, this801* method is called on a closed connection802* or the given parameters are not <code>ResultSet</code>803* constants indicating type, concurrency, and holdability804* @exception SQLFeatureNotSupportedException if the JDBC driver does not support805* this method or this method is not supported for the specified result806* set type, result set holdability and result set concurrency.807* @see ResultSet808* @since 1.4809*/810Statement createStatement(int resultSetType, int resultSetConcurrency,811int resultSetHoldability) throws SQLException;812813/**814* Creates a <code>PreparedStatement</code> object that will generate815* <code>ResultSet</code> objects with the given type, concurrency,816* and holdability.817* <P>818* This method is the same as the <code>prepareStatement</code> method819* above, but it allows the default result set820* type, concurrency, and holdability to be overridden.821*822* @param sql a <code>String</code> object that is the SQL statement to823* be sent to the database; may contain one or more '?' IN824* parameters825* @param resultSetType one of the following <code>ResultSet</code>826* constants:827* <code>ResultSet.TYPE_FORWARD_ONLY</code>,828* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or829* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>830* @param resultSetConcurrency one of the following <code>ResultSet</code>831* constants:832* <code>ResultSet.CONCUR_READ_ONLY</code> or833* <code>ResultSet.CONCUR_UPDATABLE</code>834* @param resultSetHoldability one of the following <code>ResultSet</code>835* constants:836* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or837* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>838* @return a new <code>PreparedStatement</code> object, containing the839* pre-compiled SQL statement, that will generate840* <code>ResultSet</code> objects with the given type,841* concurrency, and holdability842* @exception SQLException if a database access error occurs, this843* method is called on a closed connection844* or the given parameters are not <code>ResultSet</code>845* constants indicating type, concurrency, and holdability846* @exception SQLFeatureNotSupportedException if the JDBC driver does not support847* this method or this method is not supported for the specified result848* set type, result set holdability and result set concurrency.849* @see ResultSet850* @since 1.4851*/852PreparedStatement prepareStatement(String sql, int resultSetType,853int resultSetConcurrency, int resultSetHoldability)854throws SQLException;855856/**857* Creates a <code>CallableStatement</code> object that will generate858* <code>ResultSet</code> objects with the given type and concurrency.859* This method is the same as the <code>prepareCall</code> method860* above, but it allows the default result set861* type, result set concurrency type and holdability to be overridden.862*863* @param sql a <code>String</code> object that is the SQL statement to864* be sent to the database; may contain on or more '?' parameters865* @param resultSetType one of the following <code>ResultSet</code>866* constants:867* <code>ResultSet.TYPE_FORWARD_ONLY</code>,868* <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or869* <code>ResultSet.TYPE_SCROLL_SENSITIVE</code>870* @param resultSetConcurrency one of the following <code>ResultSet</code>871* constants:872* <code>ResultSet.CONCUR_READ_ONLY</code> or873* <code>ResultSet.CONCUR_UPDATABLE</code>874* @param resultSetHoldability one of the following <code>ResultSet</code>875* constants:876* <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or877* <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code>878* @return a new <code>CallableStatement</code> object, containing the879* pre-compiled SQL statement, that will generate880* <code>ResultSet</code> objects with the given type,881* concurrency, and holdability882* @exception SQLException if a database access error occurs, this883* method is called on a closed connection884* or the given parameters are not <code>ResultSet</code>885* constants indicating type, concurrency, and holdability886* @exception SQLFeatureNotSupportedException if the JDBC driver does not support887* this method or this method is not supported for the specified result888* set type, result set holdability and result set concurrency.889* @see ResultSet890* @since 1.4891*/892CallableStatement prepareCall(String sql, int resultSetType,893int resultSetConcurrency,894int resultSetHoldability) throws SQLException;895896897/**898* Creates a default <code>PreparedStatement</code> object that has899* the capability to retrieve auto-generated keys. The given constant900* tells the driver whether it should make auto-generated keys901* available for retrieval. This parameter is ignored if the SQL statement902* is not an <code>INSERT</code> statement, or an SQL statement able to return903* auto-generated keys (the list of such statements is vendor-specific).904* <P>905* <B>Note:</B> This method is optimized for handling906* parametric SQL statements that benefit from precompilation. If907* the driver supports precompilation,908* the method <code>prepareStatement</code> will send909* the statement to the database for precompilation. Some drivers910* may not support precompilation. In this case, the statement may911* not be sent to the database until the <code>PreparedStatement</code>912* object is executed. This has no direct effect on users; however, it does913* affect which methods throw certain SQLExceptions.914* <P>915* Result sets created using the returned <code>PreparedStatement</code>916* object will by default be type <code>TYPE_FORWARD_ONLY</code>917* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.918* The holdability of the created result sets can be determined by919* calling {@link #getHoldability}.920*921* @param sql an SQL statement that may contain one or more '?' IN922* parameter placeholders923* @param autoGeneratedKeys a flag indicating whether auto-generated keys924* should be returned; one of925* <code>Statement.RETURN_GENERATED_KEYS</code> or926* <code>Statement.NO_GENERATED_KEYS</code>927* @return a new <code>PreparedStatement</code> object, containing the928* pre-compiled SQL statement, that will have the capability of929* returning auto-generated keys930* @exception SQLException if a database access error occurs, this931* method is called on a closed connection932* or the given parameter is not a <code>Statement</code>933* constant indicating whether auto-generated keys should be934* returned935* @exception SQLFeatureNotSupportedException if the JDBC driver does not support936* this method with a constant of Statement.RETURN_GENERATED_KEYS937* @since 1.4938*/939PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)940throws SQLException;941942/**943* Creates a default <code>PreparedStatement</code> object capable944* of returning the auto-generated keys designated by the given array.945* This array contains the indexes of the columns in the target946* table that contain the auto-generated keys that should be made947* available. The driver will ignore the array if the SQL statement948* is not an <code>INSERT</code> statement, or an SQL statement able to return949* auto-generated keys (the list of such statements is vendor-specific).950*<p>951* An SQL statement with or without IN parameters can be952* pre-compiled and stored in a <code>PreparedStatement</code> object. This953* object can then be used to efficiently execute this statement954* multiple times.955* <P>956* <B>Note:</B> This method is optimized for handling957* parametric SQL statements that benefit from precompilation. If958* the driver supports precompilation,959* the method <code>prepareStatement</code> will send960* the statement to the database for precompilation. Some drivers961* may not support precompilation. In this case, the statement may962* not be sent to the database until the <code>PreparedStatement</code>963* object is executed. This has no direct effect on users; however, it does964* affect which methods throw certain SQLExceptions.965* <P>966* Result sets created using the returned <code>PreparedStatement</code>967* object will by default be type <code>TYPE_FORWARD_ONLY</code>968* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.969* The holdability of the created result sets can be determined by970* calling {@link #getHoldability}.971*972* @param sql an SQL statement that may contain one or more '?' IN973* parameter placeholders974* @param columnIndexes an array of column indexes indicating the columns975* that should be returned from the inserted row or rows976* @return a new <code>PreparedStatement</code> object, containing the977* pre-compiled statement, that is capable of returning the978* auto-generated keys designated by the given array of column979* indexes980* @exception SQLException if a database access error occurs981* or this method is called on a closed connection982* @exception SQLFeatureNotSupportedException if the JDBC driver does not support983* this method984*985* @since 1.4986*/987PreparedStatement prepareStatement(String sql, int columnIndexes[])988throws SQLException;989990/**991* Creates a default <code>PreparedStatement</code> object capable992* of returning the auto-generated keys designated by the given array.993* This array contains the names of the columns in the target994* table that contain the auto-generated keys that should be returned.995* The driver will ignore the array if the SQL statement996* is not an <code>INSERT</code> statement, or an SQL statement able to return997* auto-generated keys (the list of such statements is vendor-specific).998* <P>999* An SQL statement with or without IN parameters can be1000* pre-compiled and stored in a <code>PreparedStatement</code> object. This1001* object can then be used to efficiently execute this statement1002* multiple times.1003* <P>1004* <B>Note:</B> This method is optimized for handling1005* parametric SQL statements that benefit from precompilation. If1006* the driver supports precompilation,1007* the method <code>prepareStatement</code> will send1008* the statement to the database for precompilation. Some drivers1009* may not support precompilation. In this case, the statement may1010* not be sent to the database until the <code>PreparedStatement</code>1011* object is executed. This has no direct effect on users; however, it does1012* affect which methods throw certain SQLExceptions.1013* <P>1014* Result sets created using the returned <code>PreparedStatement</code>1015* object will by default be type <code>TYPE_FORWARD_ONLY</code>1016* and have a concurrency level of <code>CONCUR_READ_ONLY</code>.1017* The holdability of the created result sets can be determined by1018* calling {@link #getHoldability}.1019*1020* @param sql an SQL statement that may contain one or more '?' IN1021* parameter placeholders1022* @param columnNames an array of column names indicating the columns1023* that should be returned from the inserted row or rows1024* @return a new <code>PreparedStatement</code> object, containing the1025* pre-compiled statement, that is capable of returning the1026* auto-generated keys designated by the given array of column1027* names1028* @exception SQLException if a database access error occurs1029* or this method is called on a closed connection1030* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1031* this method1032*1033* @since 1.41034*/1035PreparedStatement prepareStatement(String sql, String columnNames[])1036throws SQLException;10371038/**1039* Constructs an object that implements the <code>Clob</code> interface. The object1040* returned initially contains no data. The <code>setAsciiStream</code>,1041* <code>setCharacterStream</code> and <code>setString</code> methods of1042* the <code>Clob</code> interface may be used to add data to the <code>Clob</code>.1043* @return An object that implements the <code>Clob</code> interface1044* @throws SQLException if an object that implements the1045* <code>Clob</code> interface can not be constructed, this method is1046* called on a closed connection or a database access error occurs.1047* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1048* this data type1049*1050* @since 1.61051*/1052Clob createClob() throws SQLException;10531054/**1055* Constructs an object that implements the <code>Blob</code> interface. The object1056* returned initially contains no data. The <code>setBinaryStream</code> and1057* <code>setBytes</code> methods of the <code>Blob</code> interface may be used to add data to1058* the <code>Blob</code>.1059* @return An object that implements the <code>Blob</code> interface1060* @throws SQLException if an object that implements the1061* <code>Blob</code> interface can not be constructed, this method is1062* called on a closed connection or a database access error occurs.1063* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1064* this data type1065*1066* @since 1.61067*/1068Blob createBlob() throws SQLException;10691070/**1071* Constructs an object that implements the <code>NClob</code> interface. The object1072* returned initially contains no data. The <code>setAsciiStream</code>,1073* <code>setCharacterStream</code> and <code>setString</code> methods of the <code>NClob</code> interface may1074* be used to add data to the <code>NClob</code>.1075* @return An object that implements the <code>NClob</code> interface1076* @throws SQLException if an object that implements the1077* <code>NClob</code> interface can not be constructed, this method is1078* called on a closed connection or a database access error occurs.1079* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1080* this data type1081*1082* @since 1.61083*/1084NClob createNClob() throws SQLException;10851086/**1087* Constructs an object that implements the <code>SQLXML</code> interface. The object1088* returned initially contains no data. The <code>createXmlStreamWriter</code> object and1089* <code>setString</code> method of the <code>SQLXML</code> interface may be used to add data to the <code>SQLXML</code>1090* object.1091* @return An object that implements the <code>SQLXML</code> interface1092* @throws SQLException if an object that implements the <code>SQLXML</code> interface can not1093* be constructed, this method is1094* called on a closed connection or a database access error occurs.1095* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1096* this data type1097* @since 1.61098*/1099SQLXML createSQLXML() throws SQLException;11001101/**1102* Returns true if the connection has not been closed and is still valid.1103* The driver shall submit a query on the connection or use some other1104* mechanism that positively verifies the connection is still valid when1105* this method is called.1106* <p>1107* The query submitted by the driver to validate the connection shall be1108* executed in the context of the current transaction.1109*1110* @param timeout - The time in seconds to wait for the database operation1111* used to validate the connection to complete. If1112* the timeout period expires before the operation1113* completes, this method returns false. A value of1114* 0 indicates a timeout is not applied to the1115* database operation.1116* <p>1117* @return true if the connection is valid, false otherwise1118* @exception SQLException if the value supplied for <code>timeout</code>1119* is less then 01120* @since 1.61121*1122* @see java.sql.DatabaseMetaData#getClientInfoProperties1123*/1124boolean isValid(int timeout) throws SQLException;11251126/**1127* Sets the value of the client info property specified by name to the1128* value specified by value.1129* <p>1130* Applications may use the <code>DatabaseMetaData.getClientInfoProperties</code>1131* method to determine the client info properties supported by the driver1132* and the maximum length that may be specified for each property.1133* <p>1134* The driver stores the value specified in a suitable location in the1135* database. For example in a special register, session parameter, or1136* system table column. For efficiency the driver may defer setting the1137* value in the database until the next time a statement is executed or1138* prepared. Other than storing the client information in the appropriate1139* place in the database, these methods shall not alter the behavior of1140* the connection in anyway. The values supplied to these methods are1141* used for accounting, diagnostics and debugging purposes only.1142* <p>1143* The driver shall generate a warning if the client info name specified1144* is not recognized by the driver.1145* <p>1146* If the value specified to this method is greater than the maximum1147* length for the property the driver may either truncate the value and1148* generate a warning or generate a <code>SQLClientInfoException</code>. If the driver1149* generates a <code>SQLClientInfoException</code>, the value specified was not set on the1150* connection.1151* <p>1152* The following are standard client info properties. Drivers are not1153* required to support these properties however if the driver supports a1154* client info property that can be described by one of the standard1155* properties, the standard property name should be used.1156*1157* <ul>1158* <li>ApplicationName - The name of the application currently utilizing1159* the connection</li>1160* <li>ClientUser - The name of the user that the application using1161* the connection is performing work for. This may1162* not be the same as the user name that was used1163* in establishing the connection.</li>1164* <li>ClientHostname - The hostname of the computer the application1165* using the connection is running on.</li>1166* </ul>1167* <p>1168* @param name The name of the client info property to set1169* @param value The value to set the client info property to. If the1170* value is null, the current value of the specified1171* property is cleared.1172* <p>1173* @throws SQLClientInfoException if the database server returns an error while1174* setting the client info value on the database server or this method1175* is called on a closed connection1176* <p>1177* @since 1.61178*/1179void setClientInfo(String name, String value)1180throws SQLClientInfoException;11811182/**1183* Sets the value of the connection's client info properties. The1184* <code>Properties</code> object contains the names and values of the client info1185* properties to be set. The set of client info properties contained in1186* the properties list replaces the current set of client info properties1187* on the connection. If a property that is currently set on the1188* connection is not present in the properties list, that property is1189* cleared. Specifying an empty properties list will clear all of the1190* properties on the connection. See <code>setClientInfo (String, String)</code> for1191* more information.1192* <p>1193* If an error occurs in setting any of the client info properties, a1194* <code>SQLClientInfoException</code> is thrown. The <code>SQLClientInfoException</code>1195* contains information indicating which client info properties were not set.1196* The state of the client information is unknown because1197* some databases do not allow multiple client info properties to be set1198* atomically. For those databases, one or more properties may have been1199* set before the error occurred.1200* <p>1201*1202* @param properties the list of client info properties to set1203* <p>1204* @see java.sql.Connection#setClientInfo(String, String) setClientInfo(String, String)1205* @since 1.61206* <p>1207* @throws SQLClientInfoException if the database server returns an error while1208* setting the clientInfo values on the database server or this method1209* is called on a closed connection1210*1211*/1212void setClientInfo(Properties properties)1213throws SQLClientInfoException;12141215/**1216* Returns the value of the client info property specified by name. This1217* method may return null if the specified client info property has not1218* been set and does not have a default value. This method will also1219* return null if the specified client info property name is not supported1220* by the driver.1221* <p>1222* Applications may use the <code>DatabaseMetaData.getClientInfoProperties</code>1223* method to determine the client info properties supported by the driver.1224* <p>1225* @param name The name of the client info property to retrieve1226* <p>1227* @return The value of the client info property specified1228* <p>1229* @throws SQLException if the database server returns an error when1230* fetching the client info value from the database1231*or this method is called on a closed connection1232* <p>1233* @since 1.61234*1235* @see java.sql.DatabaseMetaData#getClientInfoProperties1236*/1237String getClientInfo(String name)1238throws SQLException;12391240/**1241* Returns a list containing the name and current value of each client info1242* property supported by the driver. The value of a client info property1243* may be null if the property has not been set and does not have a1244* default value.1245* <p>1246* @return A <code>Properties</code> object that contains the name and current value of1247* each of the client info properties supported by the driver.1248* <p>1249* @throws SQLException if the database server returns an error when1250* fetching the client info values from the database1251* or this method is called on a closed connection1252* <p>1253* @since 1.61254*/1255Properties getClientInfo()1256throws SQLException;12571258/**1259* Factory method for creating Array objects.1260*<p>1261* <b>Note: </b>When <code>createArrayOf</code> is used to create an array object1262* that maps to a primitive data type, then it is implementation-defined1263* whether the <code>Array</code> object is an array of that primitive1264* data type or an array of <code>Object</code>.1265* <p>1266* <b>Note: </b>The JDBC driver is responsible for mapping the elements1267* <code>Object</code> array to the default JDBC SQL type defined in1268* java.sql.Types for the given class of <code>Object</code>. The default1269* mapping is specified in Appendix B of the JDBC specification. If the1270* resulting JDBC type is not the appropriate type for the given typeName then1271* it is implementation defined whether an <code>SQLException</code> is1272* thrown or the driver supports the resulting conversion.1273*1274* @param typeName the SQL name of the type the elements of the array map to. The typeName is a1275* database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database. This1276* is the value returned by <code>Array.getBaseTypeName</code>1277* @param elements the elements that populate the returned object1278* @return an Array object whose elements map to the specified SQL type1279* @throws SQLException if a database error occurs, the JDBC type is not1280* appropriate for the typeName and the conversion is not supported, the typeName is null or this method is called on a closed connection1281* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this data type1282* @since 1.61283*/1284Array createArrayOf(String typeName, Object[] elements) throws1285SQLException;12861287/**1288* Factory method for creating Struct objects.1289*1290* @param typeName the SQL type name of the SQL structured type that this <code>Struct</code>1291* object maps to. The typeName is the name of a user-defined type that1292* has been defined for this database. It is the value returned by1293* <code>Struct.getSQLTypeName</code>.12941295* @param attributes the attributes that populate the returned object1296* @return a Struct object that maps to the given SQL type and is populated with the given attributes1297* @throws SQLException if a database error occurs, the typeName is null or this method is called on a closed connection1298* @throws SQLFeatureNotSupportedException if the JDBC driver does not support this data type1299* @since 1.61300*/1301Struct createStruct(String typeName, Object[] attributes)1302throws SQLException;13031304//--------------------------JDBC 4.1 -----------------------------13051306/**1307* Sets the given schema name to access.1308* <P>1309* If the driver does not support schemas, it will1310* silently ignore this request.1311* <p>1312* Calling {@code setSchema} has no effect on previously created or prepared1313* {@code Statement} objects. It is implementation defined whether a DBMS1314* prepare operation takes place immediately when the {@code Connection}1315* method {@code prepareStatement} or {@code prepareCall} is invoked.1316* For maximum portability, {@code setSchema} should be called before a1317* {@code Statement} is created or prepared.1318*1319* @param schema the name of a schema in which to work1320* @exception SQLException if a database access error occurs1321* or this method is called on a closed connection1322* @see #getSchema1323* @since 1.71324*/1325void setSchema(String schema) throws SQLException;13261327/**1328* Retrieves this <code>Connection</code> object's current schema name.1329*1330* @return the current schema name or <code>null</code> if there is none1331* @exception SQLException if a database access error occurs1332* or this method is called on a closed connection1333* @see #setSchema1334* @since 1.71335*/1336String getSchema() throws SQLException;13371338/**1339* Terminates an open connection. Calling <code>abort</code> results in:1340* <ul>1341* <li>The connection marked as closed1342* <li>Closes any physical connection to the database1343* <li>Releases resources used by the connection1344* <li>Insures that any thread that is currently accessing the connection1345* will either progress to completion or throw an <code>SQLException</code>.1346* </ul>1347* <p>1348* Calling <code>abort</code> marks the connection closed and releases any1349* resources. Calling <code>abort</code> on a closed connection is a1350* no-op.1351* <p>1352* It is possible that the aborting and releasing of the resources that are1353* held by the connection can take an extended period of time. When the1354* <code>abort</code> method returns, the connection will have been marked as1355* closed and the <code>Executor</code> that was passed as a parameter to abort1356* may still be executing tasks to release resources.1357* <p>1358* This method checks to see that there is an <code>SQLPermission</code>1359* object before allowing the method to proceed. If a1360* <code>SecurityManager</code> exists and its1361* <code>checkPermission</code> method denies calling <code>abort</code>,1362* this method throws a1363* <code>java.lang.SecurityException</code>.1364* @param executor The <code>Executor</code> implementation which will1365* be used by <code>abort</code>.1366* @throws java.sql.SQLException if a database access error occurs or1367* the {@code executor} is {@code null},1368* @throws java.lang.SecurityException if a security manager exists and its1369* <code>checkPermission</code> method denies calling <code>abort</code>1370* @see SecurityManager#checkPermission1371* @see Executor1372* @since 1.71373*/1374void abort(Executor executor) throws SQLException;13751376/**1377*1378* Sets the maximum period a <code>Connection</code> or1379* objects created from the <code>Connection</code>1380* will wait for the database to reply to any one request. If any1381* request remains unanswered, the waiting method will1382* return with a <code>SQLException</code>, and the <code>Connection</code>1383* or objects created from the <code>Connection</code> will be marked as1384* closed. Any subsequent use of1385* the objects, with the exception of the <code>close</code>,1386* <code>isClosed</code> or <code>Connection.isValid</code>1387* methods, will result in a <code>SQLException</code>.1388* <p>1389* <b>Note</b>: This method is intended to address a rare but serious1390* condition where network partitions can cause threads issuing JDBC calls1391* to hang uninterruptedly in socket reads, until the OS TCP-TIMEOUT1392* (typically 10 minutes). This method is related to the1393* {@link #abort abort() } method which provides an administrator1394* thread a means to free any such threads in cases where the1395* JDBC connection is accessible to the administrator thread.1396* The <code>setNetworkTimeout</code> method will cover cases where1397* there is no administrator thread, or it has no access to the1398* connection. This method is severe in it's effects, and should be1399* given a high enough value so it is never triggered before any more1400* normal timeouts, such as transaction timeouts.1401* <p>1402* JDBC driver implementations may also choose to support the1403* {@code setNetworkTimeout} method to impose a limit on database1404* response time, in environments where no network is present.1405* <p>1406* Drivers may internally implement some or all of their API calls with1407* multiple internal driver-database transmissions, and it is left to the1408* driver implementation to determine whether the limit will be1409* applied always to the response to the API call, or to any1410* single request made during the API call.1411* <p>1412*1413* This method can be invoked more than once, such as to set a limit for an1414* area of JDBC code, and to reset to the default on exit from this area.1415* Invocation of this method has no impact on already outstanding1416* requests.1417* <p>1418* The {@code Statement.setQueryTimeout()} timeout value is independent of the1419* timeout value specified in {@code setNetworkTimeout}. If the query timeout1420* expires before the network timeout then the1421* statement execution will be canceled. If the network is still1422* active the result will be that both the statement and connection1423* are still usable. However if the network timeout expires before1424* the query timeout or if the statement timeout fails due to network1425* problems, the connection will be marked as closed, any resources held by1426* the connection will be released and both the connection and1427* statement will be unusable.1428*<p>1429* When the driver determines that the {@code setNetworkTimeout} timeout1430* value has expired, the JDBC driver marks the connection1431* closed and releases any resources held by the connection.1432* <p>1433*1434* This method checks to see that there is an <code>SQLPermission</code>1435* object before allowing the method to proceed. If a1436* <code>SecurityManager</code> exists and its1437* <code>checkPermission</code> method denies calling1438* <code>setNetworkTimeout</code>, this method throws a1439* <code>java.lang.SecurityException</code>.1440*1441* @param executor The <code>Executor</code> implementation which will1442* be used by <code>setNetworkTimeout</code>.1443* @param milliseconds The time in milliseconds to wait for the database1444* operation1445* to complete. If the JDBC driver does not support milliseconds, the1446* JDBC driver will round the value up to the nearest second. If the1447* timeout period expires before the operation1448* completes, a SQLException will be thrown.1449* A value of 0 indicates that there is not timeout for database operations.1450* @throws java.sql.SQLException if a database access error occurs, this1451* method is called on a closed connection,1452* the {@code executor} is {@code null},1453* or the value specified for <code>seconds</code> is less than 0.1454* @throws java.lang.SecurityException if a security manager exists and its1455* <code>checkPermission</code> method denies calling1456* <code>setNetworkTimeout</code>.1457* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1458* this method1459* @see SecurityManager#checkPermission1460* @see Statement#setQueryTimeout1461* @see #getNetworkTimeout1462* @see #abort1463* @see Executor1464* @since 1.71465*/1466void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException;146714681469/**1470* Retrieves the number of milliseconds the driver will1471* wait for a database request to complete.1472* If the limit is exceeded, a1473* <code>SQLException</code> is thrown.1474*1475* @return the current timeout limit in milliseconds; zero means there is1476* no limit1477* @throws SQLException if a database access error occurs or1478* this method is called on a closed <code>Connection</code>1479* @exception SQLFeatureNotSupportedException if the JDBC driver does not support1480* this method1481* @see #setNetworkTimeout1482* @since 1.71483*/1484int getNetworkTimeout() throws SQLException;1485}148614871488