Top Description Fields Constructors Methods
org.jooq.impl

pack-priv final Class ProviderEnabledConnection

extends DefaultConnection
Class Inheritance
Imports
java.sql.CallableStatement, .Connection, .PreparedStatement, .SQLException, .Statement, org.jooq.ConnectionProvider, org.jooq.tools.jdbc.DefaultConnection

Deprecated

as a consequence of DefaultConnection being deprecated. See corresponding docs for further information.

A ConnectionProvider-enabled connection.

This is a wrapper for both a connection that must be returned to a ConnectionProvider. This wrapper abstracts closing a JDBC connection when it is obtained from a data source by closing it when the Statement, PreparedStatement, or CallableStatement is closed.

Author
Lukas Eder

Field Summary

Modifier and TypeField and Description
private final ConnectionProvider

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final void
close()

Overrides org.jooq.tools.jdbc.DefaultConnection.close.

Implements java.sql.Connection.close.

Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.
public final Statement
createStatement()

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Creates a Statement object for sending SQL statements to the database.
public final Statement
createStatement(int
a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
)

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
public final Statement
createStatement(int
one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
,
int
one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
resultSetHoldability
)

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.
public final CallableStatement
prepareCall(String
an SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is specified using JDBC call escape syntax.
sql
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Creates a CallableStatement object for calling database stored procedures.
public final CallableStatement
prepareCall(String
a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters
sql
,
int
a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
public final CallableStatement
prepareCall(String
a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters
sql
,
int
one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
,
int
one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
resultSetHoldability
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency.
public final PreparedStatement
prepareStatement(String
an SQL statement that may contain one or more '?' IN parameter placeholders
sql
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a PreparedStatement object for sending parameterized SQL statements to the database.
public final PreparedStatement
prepareStatement(String
an SQL statement that may contain one or more '?' IN parameter placeholders
sql
,
int
a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS
autoGeneratedKeys
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys.
public final PreparedStatement
prepareStatement(String
a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
sql
,
int
a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency.
public final PreparedStatement
prepareStatement(String
a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters
sql
,
int
one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetType
,
int
one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE
resultSetConcurrency
,
int
one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT
resultSetHoldability
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.
public final PreparedStatement
prepareStatement(String
an SQL statement that may contain one or more '?' IN parameter placeholders
sql
,
int[]
an array of column indexes indicating the columns that should be returned from the inserted row or rows
columnIndexes
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
public final PreparedStatement
prepareStatement(String
an SQL statement that may contain one or more '?' IN parameter placeholders
sql
,
String[]
an array of column names indicating the columns that should be returned from the inserted row or rows
columnNames
)

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array.
Inherited from org.jooq.tools.jdbc.DefaultConnection:
abortbeginRequestclearWarningscommitcreateArrayOfcreateBlobcreateClobcreateNClobcreateSQLXMLcreateStructendRequestgetAutoCommitgetCataloggetClientInfogetClientInfogetDelegategetHoldabilitygetMetaDatagetNetworkTimeoutgetSchemagetTransactionIsolationgetTypeMapgetWarningsisClosedisReadOnlyisValidisWrapperFornativeSQLreleaseSavepointrollbackrollbacksetAutoCommitsetCatalogsetClientInfosetClientInfosetHoldabilitysetNetworkTimeoutsetReadOnlysetSavepointsetSavepointsetSchemasetShardingKeysetShardingKeysetShardingKeyIfValidsetShardingKeyIfValidsetTransactionIsolationsetTypeMapunwrap

Field Detail

connectionProviderback to summary
private final ConnectionProvider connectionProvider

Constructor Detail

ProviderEnabledConnectionback to summary
pack-priv ProviderEnabledConnection(ConnectionProvider connectionProvider, Connection connection)

Method Detail

closeback to summary
public final void close() throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.close.

Implements java.sql.Connection.close.

Doc from java.sql.Connection.close.

Releases this Connection object's database and JDBC resources immediately instead of waiting for them to be automatically released.

Calling the method close on a Connection object that is already closed is a no-op.

It is strongly recommended that an application explicitly commits or rolls back an active transaction prior to calling the close method. If the close method is called and there is an active transaction, the results are implementation-defined.

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs
createStatementback to summary
public final Statement createStatement() throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Doc from java.sql.Connection.createStatement.

Creates a Statement object for sending SQL statements to the database. SQL statements without parameters are normally executed using Statement objects. If the same SQL statement is executed many times, it may be more efficient to use a PreparedStatement object.

Result sets created using the returned Statement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Returns:Statement

a new default Statement object

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection
createStatementback to summary
public final Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Doc from java.sql.Connection.createStatement.

Creates a Statement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the createStatement method above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
resultSetType:int

a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

Returns:Statement

a new Statement object that will generate ResultSet objects with the given type and concurrency

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type and concurrency
createStatementback to summary
public final Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.createStatement.

Implements java.sql.Connection.createStatement.

Doc from java.sql.Connection.createStatement.

Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability. This method is the same as the createStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.

Parameters
resultSetType:int

one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

resultSetHoldability:int

one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT

Returns:Statement

a new Statement object that will generate ResultSet objects with the given type, concurrency, and holdability

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
prepareCallback to summary
public final CallableStatement prepareCall(String sql) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Doc from java.sql.Connection.prepareCall.

Creates a CallableStatement object for calling database stored procedures. The CallableStatement object provides methods for setting up its IN and OUT 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 method prepareCall is done; others may wait until the CallableStatement object is executed. This has no direct effect on users; however, it does affect which method throws certain SQLExceptions.

Result sets created using the returned CallableStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

an SQL statement that may contain one or more '?' parameter placeholders. Typically this statement is specified using JDBC call escape syntax.

Returns:CallableStatement

a new default CallableStatement object containing the pre-compiled SQL statement

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection
prepareCallback to summary
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Doc from java.sql.Connection.prepareCall.

Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters

resultSetType:int

a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

Returns:CallableStatement

a new CallableStatement object containing the pre-compiled SQL statement that will produce ResultSet objects with the given type and concurrency

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type and concurrency
prepareCallback to summary
public final CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareCall.

Implements java.sql.Connection.prepareCall.

Doc from java.sql.Connection.prepareCall.

Creates a CallableStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareCall method above, but it allows the default result set type, result set concurrency type and holdability to be overridden.

Parameters
sql:String

a String object that is the SQL statement to be sent to the database; may contain on or more '?' parameters

resultSetType:int

one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

resultSetHoldability:int

one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT

Returns:CallableStatement

a new CallableStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a PreparedStatement object for sending parameterized SQL statements to the database.

A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. 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 method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLException objects.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

an SQL statement that may contain one or more '?' IN parameter placeholders

Returns:PreparedStatement

a new default PreparedStatement object containing the pre-compiled SQL statement

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object that has the capability to retrieve auto-generated keys. The given constant tells the driver whether it should make auto-generated keys available for retrieval. This parameter is ignored if the SQL statement is not an INSERT statement, or an SQL statement able to return auto-generated keys (the list 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 method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

an SQL statement that may contain one or more '?' IN parameter placeholders

autoGeneratedKeys:int

a flag indicating whether auto-generated keys should be returned; one of Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS

Returns:PreparedStatement

a new PreparedStatement object, containing the pre-compiled SQL statement, that will have the capability of returning auto-generated keys

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameter is not a Statement constant indicating whether auto-generated keys should be returned
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a PreparedStatement object that will generate ResultSet objects with the given type and concurrency. This method is the same as the prepareStatement method above, but it allows the default result set type and concurrency to be overridden. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters

resultSetType:int

a result set type; one of ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

a concurrency type; one of ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

Returns:PreparedStatement

a new PreparedStatement object containing the pre-compiled SQL statement that will produce ResultSet objects with the given type and concurrency

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type and concurrency
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a PreparedStatement object that will generate ResultSet objects with the given type, concurrency, and holdability.

This method is the same as the prepareStatement method above, but it allows the default result set type, concurrency, and holdability to be overridden.

Parameters
sql:String

a String object that is the SQL statement to be sent to the database; may contain one or more '?' IN parameters

resultSetType:int

one of the following ResultSet constants: ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_INSENSITIVE, or ResultSet.TYPE_SCROLL_SENSITIVE

resultSetConcurrency:int

one of the following ResultSet constants: ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE

resultSetHoldability:int

one of the following ResultSet constants: ResultSet.HOLD_CURSORS_OVER_COMMIT or ResultSet.CLOSE_CURSORS_AT_COMMIT

Returns:PreparedStatement

a new PreparedStatement object, containing the pre-compiled SQL statement, that will generate ResultSet objects with the given type, concurrency, and holdability

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs, this method is called on a closed connection or the given parameters are not ResultSet constants indicating type, concurrency, and holdability
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the indexes of the 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 not an INSERT statement, 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 PreparedStatement object. 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 method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

an SQL statement that may contain one or more '?' IN parameter placeholders

columnIndexes:int[]

an array of column indexes indicating the columns that should be returned from the inserted row or rows

Returns:PreparedStatement

a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column indexes

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection
prepareStatementback to summary
public final PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.prepareStatement.

Implements java.sql.Connection.prepareStatement.

Doc from java.sql.Connection.prepareStatement.

Creates a default PreparedStatement object capable of returning the auto-generated keys designated by the given array. This array contains the names of the 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 an INSERT statement, 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 PreparedStatement object. 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 method prepareStatement will send the statement to the database for precompilation. Some drivers may not support precompilation. In this case, the statement may not be sent to the database until the PreparedStatement object is executed. This has no direct effect on users; however, it does affect which methods throw certain SQLExceptions.

Result sets created using the returned PreparedStatement object will by default be type TYPE_FORWARD_ONLY and have a concurrency level of CONCUR_READ_ONLY. The holdability of the created result sets can be determined by calling getHoldability.

Parameters
sql:String

an SQL statement that may contain one or more '?' IN parameter placeholders

columnNames:String[]

an array of column names indicating the columns that should be returned from the inserted row or rows

Returns:PreparedStatement

a new PreparedStatement object, containing the pre-compiled statement, that is capable of returning the auto-generated keys designated by the given array of column names

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection