Top Description Fields Constructors Methods
org.jooq.tools.jdbc

public Class LoggingConnection

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

Deprecated

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

A JDBC Connection proxy that logs all statements that are prepared or executed using it.
Author
Lukas Eder

Field Summary

Modifier and TypeField and Description
private static final JooqLogger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public 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 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 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 String
nativeSQL(String
an SQL statement that may contain one or more '?' parameter placeholders
sql
)

Overrides org.jooq.tools.jdbc.DefaultConnection.nativeSQL.

Implements java.sql.Connection.nativeSQL.

Converts the given SQL statement into the system's native SQL grammar.
public 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 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 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 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 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 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 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 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 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:
abortbeginRequestclearWarningsclosecommitcreateArrayOfcreateBlobcreateClobcreateNClobcreateSQLXMLcreateStructendRequestgetAutoCommitgetCataloggetClientInfogetClientInfogetDelegategetHoldabilitygetMetaDatagetNetworkTimeoutgetSchemagetTransactionIsolationgetTypeMapgetWarningsisClosedisReadOnlyisValidisWrapperForreleaseSavepointrollbackrollbacksetAutoCommitsetCatalogsetClientInfosetClientInfosetHoldabilitysetNetworkTimeoutsetReadOnlysetSavepointsetSavepointsetSchemasetShardingKeysetShardingKeysetShardingKeyIfValidsetShardingKeyIfValidsetTransactionIsolationsetTypeMapunwrap

Field Detail

logback to summary
private static final JooqLogger log

Constructor Detail

LoggingConnectionback to summary
public LoggingConnection(Connection delegate)

Method Detail

createStatementback to summary
public 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 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 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
nativeSQLback to summary
public String nativeSQL(String sql) throws SQLException

Overrides org.jooq.tools.jdbc.DefaultConnection.nativeSQL.

Implements java.sql.Connection.nativeSQL.

Doc from java.sql.Connection.nativeSQL.

Converts the given SQL statement into the system's native SQL grammar. A driver may convert the JDBC SQL grammar into its system's native SQL grammar prior to sending it. This method returns the native form of the statement that the driver would have sent.

Parameters
sql:String

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

Returns:String

the native form of this statement

Annotations
@Override
Exceptions
SQLException:
if a database access error occurs or this method is called on a closed connection
prepareCallback to summary
public 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 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 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 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 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 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 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 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 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