|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.driver.Connection
This Connection
class implements a virtual connection that is
just used to store the needed information when the real connection will have
to be established by the Controller to execute a query.
This code has been inspired from the PostgreSQL JDBC driver by Peter T. Mount.
Field Summary | |
protected boolean |
autoCommit
Commit mode of the connection ( true = automatic). |
protected Driver |
driver
Driver that created us. |
protected java.sql.SQLWarning |
firstWarning
List of Warnings for this connection. |
protected boolean |
isClosed
Status of the connection. |
protected int |
isolationLevel
Isolation level. |
private static int |
MAX_RECONNECT_ATTEMPTS
|
protected DatabaseMetaData |
metaData
Meta-data of C-JDBC connections. |
protected boolean |
needSqlSkeleton
Does the controller require the SQL skeleton? |
private int |
objectsOnStream
|
protected boolean |
readOnly
Is the connection in read-only mode ? |
private int |
reconnectRetries
|
protected java.net.Socket |
socket
Connection with the controller. |
protected java.io.ObjectInputStream |
socketInput
Socket input stream. |
protected java.io.ObjectOutputStream |
socketOutput
Socket output stream. |
private static int |
STREAM_GC_LIMIT
|
protected int |
transactionId
transaction identifier. |
protected java.lang.String |
url
C-JDBC URL of the database. |
protected VirtualDatabaseUser |
vdbUser
Virtual database user used for this connection. |
Fields inherited from interface java.sql.Connection |
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE |
Constructor Summary | |
Connection()
Creates a new Connection instance. |
|
Connection(Driver driver,
java.net.Socket socket,
java.io.ObjectInputStream in,
java.io.ObjectOutputStream out,
java.lang.String url,
VirtualDatabaseUser virtualDatabaseUser,
boolean sqlSkeletonNeeded)
Creates a new Connection instance. |
Method Summary | |
void |
clearWarnings()
After this call, getWarnings() returns null
until a new warning is reported for this connection. |
void |
close()
Releases the connection. |
void |
commit()
Makes all changes made since the previous commit/rollback permanent and releases any database locks currently held by the Connection .
|
java.sql.Statement |
createStatement()
SQL statements without parameters are normally executed using Statement
objects. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
SQL statements without parameters are normally executed using Statement
objects. |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a Statement object that will generate ResultSet
objects with the given type, concurrency, and holdability.
|
protected java.sql.ResultSet |
execReadRequest(SelectRequest request)
Performs a read request and return the reply. |
java.sql.ResultSet |
execReadStoredProcedure(StoredProcedure proc)
Call a stored procedure that returns a ResultSet. |
protected int |
execWriteRequest(AbstractWriteRequest request)
Performs a write request and return the number of rows affected. |
protected java.sql.ResultSet |
execWriteRequestWithKeys(AbstractWriteRequest request)
Performs a write request and return the number of rows affected. |
protected int |
execWriteStoredProcedure(StoredProcedure proc)
Call a stored procedure that performs an update. |
protected void |
finalize()
|
boolean |
getAutoCommit()
Gets the current auto-commit state. |
java.lang.String |
getCatalog()
C-JDBC does NOT handle catalogs. |
protected java.sql.ResultSet |
getColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String columnNamePattern)
|
java.lang.String |
getControllerVersionNumber()
Get the C-JDBC controller version number. |
int |
getHoldability()
Retrieves the current holdability of ResultSet objects
created using this Connection object. |
java.sql.DatabaseMetaData |
getMetaData()
A connection's database is able to provide information describing its tables, its supported SQL grammar, its stored procedures, the capabilities of this connection, etc. |
java.lang.String |
getPassword()
Gets the password used to login to the database. |
protected java.sql.ResultSet |
getPrimaryKeys(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern)
|
protected java.sql.ResultSet |
getProcedureColumns(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String procedureNamePattern,
java.lang.String columnNamePattern)
|
protected java.sql.ResultSet |
getProcedures(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String procedureNamePattern)
|
protected java.sql.ResultSet |
getTables(java.lang.String catalog,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String[] types)
|
int |
getTransactionIsolation()
Gets this Connection's current transaction isolation mode. |
java.util.Map |
getTypeMap()
C-JDBC does NOT support type map. |
java.lang.String |
getURL()
Gets the C-JDBC URL of the database of the connection. |
java.lang.String |
getUserName()
Gets the user name used to login to the database. |
java.sql.SQLWarning |
getWarnings()
The first warning reported by calls on this connection is returned. |
boolean |
isClosed()
Returns true if the connection is closed (no real meaning
from C-JDBC point of view) |
boolean |
isReadOnly()
Tests to see if the connection is in read only Mode. |
java.lang.String |
nativeSQL(java.lang.String query)
As we can't know for sure which database will execute this request (now or later), we can't translate it in the native query language of the underlying DBMS. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Creates a CallableStatement that contains sql and produces a ResultSet that is TYPE_SCROLL_INSENSITIVE and CONCUR_READ_ONLY. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Stored procedure call are not yet supported by C-JDBC. |
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a CallableStatement object that will generate ResultSet
objects with the given type and concurrency. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
A SQL statement with or without IN parameters can be
pre-compiled and stored in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Creates a default PreparedStatement object that has the
capability to retrieve auto-generated keys. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Creates a default PreparedStatement object capable of
returning the auto-generated keys designated by the given array. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
A SQL statement with or without IN parameters can be pre-compiled and stored in a PreparedStatement object. |
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a PreparedStatement object that will generate ResultSet
objects with the given type, concurrency, and holdability.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Creates a default PreparedStatement object capable of
returning the auto-generated keys designated by the given array. |
private void |
reconnect()
|
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Removes the given Savepoint object from the current
transaction. |
void |
rollback()
Drops all changes made since the previous commit/rollback and releases any database locks currently held by this connection. |
void |
rollback(java.sql.Savepoint savepoint)
Undoes all changes made after the given Savepoint object was
set.
|
void |
setAutoCommit(boolean autoCommit)
If a connection is in auto-commit mode, then all its SQL statements will be executed and committed as individual transactions. |
void |
setCatalog(java.lang.String catalog)
C-JDBC does NOT support catalogs. |
protected void |
setConnectionParametersOnRequest(AbstractRequest request)
Set the login, transaction id and autocommit mode on this request. |
void |
setHoldability(int holdability)
Changes the holdability of ResultSet objects created using
this Connection object to the given holdability. |
void |
setReadOnly(boolean readOnly)
You can put a connection in read-only mode as a hint to enable database optimizations Note: setReadOnly cannot be called while in the middle of a transaction |
java.sql.Savepoint |
setSavepoint()
Creates an unnamed savepoint in the current transaction and returns the new Savepoint object that represents it. |
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a savepoint with the given name in the current transaction and returns the new Savepoint object that represents it. |
void |
setTransactionIsolation(int level)
You can call this method to try to change the transaction isolation level using one of the TRANSACTION_* values. |
void |
setTypeMap(java.util.Map map)
C-JDBC does NOT support type map. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean autoCommit
true
= automatic).
protected boolean isClosed
protected boolean readOnly
protected int isolationLevel
protected int transactionId
protected boolean needSqlSkeleton
protected java.sql.SQLWarning firstWarning
Warnings
for this connection.
protected DatabaseMetaData metaData
protected Driver driver
protected java.lang.String url
protected VirtualDatabaseUser vdbUser
protected java.net.Socket socket
protected java.io.ObjectInputStream socketInput
protected java.io.ObjectOutputStream socketOutput
private static final int STREAM_GC_LIMIT
private int objectsOnStream
private int reconnectRetries
private static final int MAX_RECONNECT_ATTEMPTS
Constructor Detail |
public Connection()
Connection
instance.
public Connection(Driver driver, java.net.Socket socket, java.io.ObjectInputStream in, java.io.ObjectOutputStream out, java.lang.String url, VirtualDatabaseUser virtualDatabaseUser, boolean sqlSkeletonNeeded)
Connection
instance.
driver
- calling driversocket
- connection with the controllerin
- socket input streamout
- socket output streamurl
- C-JDBC URL of the databasevirtualDatabaseUser
- user login/passwordsqlSkeletonNeeded
- true if SQL skeletons must be sent to the
controllerMethod Detail |
protected void finalize() throws java.lang.Throwable
java.lang.Throwable
Object.finalize()
public java.lang.String getURL()
public java.lang.String getUserName()
public java.lang.String getPassword()
public void clearWarnings() throws java.sql.SQLException
getWarnings()
returns null
until a new warning is reported for this connection.
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic void close() throws java.sql.SQLException
ConnectionClosingThread
if the connection has not been reused before.
close
in interface java.sql.Connection
java.sql.SQLException
- if an error occurspublic void commit() throws java.sql.SQLException
Connection
.
This method should only be used when auto-commit has been disabled. (If
autoCommit
==true
, then we just return
anyhow)
commit
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurssetAutoCommit(boolean)
public java.sql.Statement createStatement() throws java.sql.SQLException
Statement
objects. If the same SQL statement is executed many times, it is more
efficient to use a PreparedStatement
. The ResultSet
will be TYPE_FORWARD_ONLY/CONCUR_READ_ONLY
.
*
- Specified by:
createStatement
in interface java.sql.Connection
- Returns:
- a new
Statement
object
- Throws:
java.sql.SQLException
- passed through from the constructor
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
Statement
objects. If the same SQL statement is executed many times, it is more
efficient to use a PreparedStatement
.
createStatement
in interface java.sql.Connection
resultSetType
- resultSetType to useresultSetConcurrency
- resultSetConcurrency to use
Statement
object
java.sql.SQLException
- passed through from the constructorpublic boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
- (why?)setAutoCommit(boolean)
public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic java.sql.DatabaseMetaData getMetaData() throws java.sql.SQLException
getMetaData
in interface java.sql.Connection
DatabaseMetaData
object for this connection
java.sql.SQLException
- if a database access error occursprotected java.sql.ResultSet getProcedures(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String procedureNamePattern) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.ResultSet getProcedureColumns(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String procedureNamePattern, java.lang.String columnNamePattern) throws java.sql.SQLException
java.sql.SQLException
public int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
TRANSACTION_*
mode value
java.sql.SQLException
- if a database access error occurspublic java.util.Map getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
- not supportedpublic java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurspublic boolean isClosed() throws java.sql.SQLException
true
if the connection is closed (no real meaning
from C-JDBC point of view)
isClosed
in interface java.sql.Connection
true
if connection has never been opened or close()
has been called
java.sql.SQLException
- if an error occurspublic boolean isReadOnly() throws java.sql.SQLException
readOnly
flag.
isReadOnly
in interface java.sql.Connection
true
if the connection is read only
java.sql.SQLException
- if a database access error occurspublic java.lang.String nativeSQL(java.lang.String query) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
query
- the query to change
java.sql.SQLException
- neverpublic java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- SQL request
java.sql.SQLException
- not supportedpublic java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
sql
- a String
valueresultSetType
- an int
valueresultSetConcurrency
- an int
value
java.sql.SQLException
- not supportedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
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.
prepareStatement
in interface java.sql.Connection
sql
- a SQL statement that may contain one or more '?' IN * parameter
placeholders
PreparedStatement
object containing the
pre-compiled statement.
java.sql.SQLException
- if a database access error occurs.public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
PreparedStatement
object. This object can then
be used to efficiently execute this statement multiple times.
prepareStatement
in interface java.sql.Connection
sql
- a SQL statement that may contain one or more '?' INresultSetType
- ResultSetType
to useresultSetConcurrency
- ResultSetConcurrency
to use
PreparedStatement
object
java.sql.SQLException
- passed through from the constructorpublic void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
- if a database access error occurscommit()
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
commit()
or rollback()
. By default, new connections are
in auto-commit mode. The commit occurs when the statement completes or the
next execute occurs, whichever comes first. In the case of statements
returning a ResultSet
, the statement completes when the
last row of the ResultSet
has been retrieved or the ResultSet
has been closed. In advanced cases, a single statement may return multiple
results as well as output parameter values. Here the commit occurs when all
results and output param values have been retrieved.
setAutoCommit
in interface java.sql.Connection
autoCommit
- true
enables auto-commit; false
disables it
java.sql.SQLException
- if a database access error occurspublic void setCatalog(java.lang.String catalog) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
catalog
- a String
value
java.sql.SQLException
- not supportedpublic void setReadOnly(boolean readOnly) throws java.sql.SQLException
Note: setReadOnly cannot be called while in the middle of a transaction
setReadOnly
in interface java.sql.Connection
readOnly
- true
enables read-only mode; false
disables it
java.sql.SQLException
- if a database access error occurspublic void setTransactionIsolation(int level) throws java.sql.SQLException
Note: this method cannot be called while in the middle of a transaction.
setTransactionIsolation
in interface java.sql.Connection
level
- one of the TRANSACTION_* isolation values with * the exception
of TRANSACTION_NONE; some databases may * not support other values
java.sql.SQLException
- if a database access error occursDatabaseMetaData.supportsTransactionIsolationLevel(int)
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
map
- ignored
java.sql.SQLException
- not supportedprotected void setConnectionParametersOnRequest(AbstractRequest request)
request
- The request to setprotected java.sql.ResultSet execReadRequest(SelectRequest request) throws java.sql.SQLException
request
- the read request to execute
java.sql.ResultSet
value
java.sql.SQLException
- if an error occursprivate void reconnect() throws java.sql.SQLException
java.sql.SQLException
protected int execWriteRequest(AbstractWriteRequest request) throws java.sql.SQLException
request
- the write request to execute
java.sql.SQLException
- if an error occursprotected java.sql.ResultSet execWriteRequestWithKeys(AbstractWriteRequest request) throws java.sql.SQLException
request
- the write request to execute
java.sql.SQLException
- if an error occurspublic java.sql.ResultSet execReadStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
java.sql.ResultSet
value
java.sql.SQLException
- if an error occursprotected int execWriteStoredProcedure(StoredProcedure proc) throws java.sql.SQLException
proc
- the stored procedure call
java.sql.SQLException
- if an error occursprotected java.sql.ResultSet getColumns(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String columnNamePattern) throws java.sql.SQLException
java.sql.SQLException
protected java.sql.ResultSet getPrimaryKeys(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern) throws java.sql.SQLException
java.sql.SQLException
java.sql.DatabaseMetadata#getPrimaryKeys
protected java.sql.ResultSet getTables(java.lang.String catalog, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String[] types) throws java.sql.SQLException
java.sql.SQLException
DatabaseMetaData.getTables(String, String,
String, String[])
public java.lang.String getControllerVersionNumber() throws java.sql.SQLException
java.sql.SQLException
- if an error occurspublic void setHoldability(int holdability) throws java.sql.SQLException
ResultSet
objects created using
this Connection
object to the given holdability.
setHoldability
in interface java.sql.Connection
holdability
- a ResultSet
holdability constant; one of
ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
- if a database access occurs, the given parameter is
not a ResultSet
constant indicating holdability, or the
given holdability is not supportedgetHoldability()
,
ResultSet
public int getHoldability() throws java.sql.SQLException
ResultSet
objects
created using this Connection
object.
getHoldability
in interface java.sql.Connection
ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMIT
java.sql.SQLException
- if a database access occurssetHoldability(int)
,
ResultSet
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
Savepoint
object that represents it.
setSavepoint
in interface java.sql.Connection
Savepoint
object
java.sql.SQLException
- if a database access error occurs or this Connection
object is currently in auto-commit modeSavepoint
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
Savepoint
object that represents it.
setSavepoint
in interface java.sql.Connection
name
- a String
containing the name of the savepoint
Savepoint
object
java.sql.SQLException
- if a database access error occurs or this Connection
object is currently in auto-commit modeSavepoint
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
Savepoint
object was
set.
This method should be used only when auto-commit has been disabled.
rollback
in interface java.sql.Connection
savepoint
- the Savepoint
object to roll back to
java.sql.SQLException
- if a database access error occurs, the Savepoint
object is no longer valid, or this Connection
object is
currently in auto-commit modeSavepoint
,
rollback()
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
Savepoint
object from the current
transaction. Any reference to the savepoint after it have been removed will
cause an SQLException
to be thrown.
releaseSavepoint
in interface java.sql.Connection
savepoint
- the Savepoint
object to be removed
java.sql.SQLException
- if a database access error occurs or the given
Savepoint
object is not a valid savepoint in the current
transactionpublic java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
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.
createStatement
in interface java.sql.Connection
resultSetType
- one of the following ResultSet
constants: ResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
,
or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency
- one of the following ResultSet
constants: ResultSet.CONCUR_READ_ONLY
or ResultSet.CONCUR_UPDATABLE
resultSetHoldability
- one of the following ResultSet
constants: ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMIT
Statement
object that will generate ResultSet
objects with the given type, concurrency, and holdability
java.sql.SQLException
- if a database access error occurs or the given
parameters are not ResultSet
constants indicating type,
concurrency, and holdabilityResultSet
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
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.
prepareStatement
in interface java.sql.Connection
sql
- a String
object that is the SQL statement to be
sent to the database; may contain one or more ? IN parametersresultSetType
- one of the following ResultSet
constants: ResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
,
or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency
- one of the following ResultSet
constants: ResultSet.CONCUR_READ_ONLY
or ResultSet.CONCUR_UPDATABLE
resultSetHoldability
- one of the following ResultSet
constants: ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMIT
PreparedStatement
object, containing the
pre-compiled SQL statement, that will generate ResultSet
objects with the given type, concurrency, and holdability
java.sql.SQLException
- if a database access error occurs or the given
parameters are not ResultSet
constants indicating type,
concurrency, and holdabilityResultSet
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
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.
prepareCall
in interface java.sql.Connection
sql
- a String
object that is the SQL statement to be
sent to the database; may contain on or more ? parametersresultSetType
- one of the following ResultSet
constants: ResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
,
or ResultSet.TYPE_SCROLL_SENSITIVE
resultSetConcurrency
- one of the following ResultSet
constants: ResultSet.CONCUR_READ_ONLY
or ResultSet.CONCUR_UPDATABLE
resultSetHoldability
- one of the following ResultSet
constants: ResultSet.HOLD_CURSORS_OVER_COMMIT
or ResultSet.CLOSE_CURSORS_AT_COMMIT
CallableStatement
object, containing the
pre-compiled SQL statement, that will generate ResultSet
objects with the given type, concurrency, and holdability
java.sql.SQLException
- if a database access error occurs or the given
parameters are not ResultSet
constants indicating type,
concurrency, and holdabilityResultSet
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
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.
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
.
prepareStatement
in interface java.sql.Connection
sql
- an SQL statement that may contain one or more '?' IN parameter
placeholdersautoGeneratedKeys
- a flag indicating whether auto-generated keys
should be returned; one of Statement.RETURN_GENERATED_KEYS
or Statement.NO_GENERATED_KEYS
PreparedStatement
object, containing the
pre-compiled SQL statement, that will have the capability of returning
auto-generated keys
java.sql.SQLException
- if a database access error occurs or the given
parameter is not a Statement
constant indicating whether
auto-generated keys should be returnedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
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. This array is ignored if
the SQL statement is not an INSERT
statement.
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
.
prepareStatement
in interface java.sql.Connection
sql
- an SQL statement that may contain one or more '?' IN parameter
placeholderscolumnIndexes
- an array of column indexes indicating the columns that
should be returned from the inserted row or rows
PreparedStatement
object, containing the
pre-compiled statement, that is capable of returning the auto-generated
keys designated by the given array of column indexes
java.sql.SQLException
- if a database access error occurspublic java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
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. This array is ignored if the
SQL statement is not an INSERT
statement.
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
.
prepareStatement
in interface java.sql.Connection
sql
- an SQL statement that may contain one or more '?' IN parameter
placeholderscolumnNames
- an array of column names indicating the columns that
should be returned from the inserted row or rows
PreparedStatement
object, containing the
pre-compiled statement, that is capable of returning the auto-generated
keys designated by the given array of column names
java.sql.SQLException
- if a database access error occurs
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |