public class JdbcConnection extends TraceObject implements java.sql.Connection, JdbcConnectionBackwardsCompat
Represents a connection (session) to a database.
Thread safety: the connection is thread-safe, because access is synchronized. However, for compatibility with other databases, a connection should only be used in one thread at any time.
ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, STATEMENT, trace, XA_DATA_SOURCE, XID| Constructor and Description |
|---|
JdbcConnection(ConnectionInfo ci,
boolean useBaseDir)
INTERNAL
|
JdbcConnection(JdbcConnection clone)
INTERNAL
|
JdbcConnection(SessionInterface session,
java.lang.String user,
java.lang.String url)
INTERNAL
|
JdbcConnection(java.lang.String url,
java.util.Properties info)
INTERNAL
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort(java.util.concurrent.Executor executor)
[Not supported]
|
protected void |
afterWriting()
INTERNAL.
|
protected void |
checkClosed()
INTERNAL.
|
protected void |
checkClosed(boolean write)
INTERNAL.
|
void |
clearWarnings()
Clears all warnings.
|
void |
close()
Closes this connection.
|
void |
commit()
Commits the current transaction.
|
java.sql.Array |
createArrayOf(java.lang.String typeName,
java.lang.Object[] elements)
Create a new Array object.
|
java.sql.Blob |
createBlob()
Create a new empty Blob object.
|
Value |
createBlob(java.io.InputStream x,
long length)
Create a Blob value from this input stream.
|
java.sql.Clob |
createClob()
Create a new empty Clob object.
|
Value |
createClob(java.io.Reader x,
long length)
Create a Clob value from this reader.
|
java.sql.NClob |
createNClob()
Create a new empty NClob object.
|
java.sql.SQLXML |
createSQLXML()
[Not supported] Create a new empty SQLXML object.
|
java.sql.Statement |
createStatement()
Creates a new statement.
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Creates a statement with the specified result set type and concurrency.
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a statement with the specified result set type, concurrency, and
holdability.
|
java.sql.Struct |
createStruct(java.lang.String typeName,
java.lang.Object[] attributes)
[Not supported] Create a new empty Struct object.
|
boolean |
getAutoCommit()
Gets the current setting for auto commit.
|
java.lang.String |
getCatalog()
Gets the current catalog name.
|
java.util.Properties |
getClientInfo()
Get the client properties.
|
java.lang.String |
getClientInfo(java.lang.String name)
Get a client property.
|
int |
getHoldability()
Returns the current result set holdability.
|
java.sql.DatabaseMetaData |
getMetaData()
Gets the database meta data for this database.
|
int |
getNetworkTimeout()
[Not supported]
|
int |
getPowerOffCount()
INTERNAL
|
java.lang.String |
getSchema()
Retrieves this current schema name for this connection.
|
SessionInterface |
getSession()
INTERNAL
|
int |
getTransactionIsolation()
Returns the current transaction isolation level.
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
getTypeMap()
Gets the type map.
|
java.sql.SQLWarning |
getWarnings()
Gets the first warning reported by calls on this object.
|
boolean |
isClosed()
Returns true if this connection has been closed.
|
boolean |
isReadOnly()
Returns true if the database is read-only.
|
boolean |
isValid(int timeout)
Returns true if this connection is still valid.
|
boolean |
isWrapperFor(java.lang.Class<?> iface)
Checks if unwrap can return an object of this class.
|
java.lang.String |
nativeSQL(java.lang.String sql)
Translates a SQL statement into the database grammar.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql)
Creates a new callable statement.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Creates a callable statement with the specified result set type and
concurrency.
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a callable statement with the specified result set type,
concurrency, and holdability.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql)
Creates a new prepared statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
Creates a new prepared statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes)
Creates a new prepared statement.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
Creates a prepared statement with the specified result set type and
concurrency.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a prepared statement with the specified result set type,
concurrency, and holdability.
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
Creates a new prepared statement.
|
void |
releaseSavepoint(java.sql.Savepoint savepoint)
Releases a savepoint.
|
void |
rollback()
Rolls back the current transaction.
|
void |
rollback(java.sql.Savepoint savepoint)
Rolls back to a savepoint.
|
void |
setAutoCommit(boolean autoCommit)
Switches auto commit on or off.
|
void |
setCatalog(java.lang.String catalog)
Set the default catalog name.
|
void |
setClientInfo(java.util.Properties properties)
Set the client properties.
|
void |
setClientInfo(java.lang.String name,
java.lang.String value)
Set a client property.
|
void |
setExecutingStatement(java.sql.Statement stat)
INTERNAL
|
void |
setHoldability(int holdability)
Changes the current result set holdability.
|
void |
setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds)
[Not supported]
|
void |
setPowerOffCount(int count)
INTERNAL
|
void |
setQueryTimeout(int seconds)
INTERNAL
|
void |
setReadOnly(boolean readOnly)
According to the JDBC specs, this setting is only a hint to the database
to enable optimizations - it does not cause writes to be prohibited.
|
java.sql.Savepoint |
setSavepoint()
Creates a new unnamed savepoint.
|
java.sql.Savepoint |
setSavepoint(java.lang.String name)
Creates a new named savepoint.
|
void |
setSchema(java.lang.String schema)
Sets the given schema name to access.
|
void |
setTraceLevel(int level)
INTERNAL
|
void |
setTransactionIsolation(int level)
Changes the current transaction isolation level.
|
void |
setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)
[Partially supported] Sets the type map.
|
java.lang.String |
toString()
INTERNAL
|
<T> T |
unwrap(java.lang.Class<T> iface)
Return an object of this class if possible.
|
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupportedpublic JdbcConnection(java.lang.String url,
java.util.Properties info)
throws java.sql.SQLException
java.sql.SQLExceptionpublic JdbcConnection(ConnectionInfo ci, boolean useBaseDir) throws java.sql.SQLException
java.sql.SQLExceptionpublic JdbcConnection(JdbcConnection clone)
public JdbcConnection(SessionInterface session, java.lang.String user, java.lang.String url)
public java.sql.Statement createStatement()
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
createStatement in interface java.sql.ConnectionresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)java.sql.SQLException - if the connection is closed or the result set type
or concurrency are not supportedpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
createStatement in interface java.sql.ConnectionresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)java.sql.SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementjava.sql.SQLException - if the connection is closedpublic java.sql.DatabaseMetaData getMetaData()
throws java.sql.SQLException
getMetaData in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic SessionInterface getSession()
public void close()
throws java.sql.SQLException
close in interface java.lang.AutoCloseableclose in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
setAutoCommit in interface java.sql.ConnectionautoCommit - true for auto commit on, false for offjava.sql.SQLException - if the connection is closedpublic boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionsql - the SQL statement with or without JDBC escape sequencesjava.sql.SQLException - if the connection is closedpublic void setReadOnly(boolean readOnly)
throws java.sql.SQLException
setReadOnly in interface java.sql.ConnectionreadOnly - ignoredjava.sql.SQLException - if the connection is closedpublic boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectioncatalog - ignoredjava.sql.SQLException - if the connection is closedpublic java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic java.sql.SQLWarning getWarnings()
throws java.sql.SQLException
getWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic void clearWarnings()
throws java.sql.SQLException
clearWarnings in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)java.sql.SQLException - if the connection is closed or the result set type
or concurrency are not supportedpublic void setTransactionIsolation(int level)
throws java.sql.SQLException
setTransactionIsolation in interface java.sql.Connectionlevel - the new transaction isolation level:
Connection.TRANSACTION_READ_UNCOMMITTED,
Connection.TRANSACTION_READ_COMMITTED, or
Connection.TRANSACTION_SERIALIZABLEjava.sql.SQLException - if the connection is closed or the isolation level
is not supportedpublic void setQueryTimeout(int seconds)
throws java.sql.SQLException
java.sql.SQLExceptionpublic int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic void setHoldability(int holdability)
throws java.sql.SQLException
setHoldability in interface java.sql.Connectionholdability - ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT;java.sql.SQLException - if the connection is closed or the holdability is
not supportedpublic int getHoldability()
throws java.sql.SQLException
getHoldability in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
throws java.sql.SQLException
getTypeMap in interface java.sql.Connectionjava.sql.SQLException - if the connection is closedpublic void setTypeMap(java.util.Map<java.lang.String,java.lang.Class<?>> map)
throws java.sql.SQLException
setTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionsql - the SQL statementjava.sql.SQLException - if the connection is closed or the statement is not
validpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)java.sql.SQLException - if the connection is closed or the result set type
or concurrency are not supportedpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)java.sql.SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic java.sql.Savepoint setSavepoint()
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Savepoint setSavepoint(java.lang.String name)
throws java.sql.SQLException
setSavepoint in interface java.sql.Connectionname - the savepoint namejava.sql.SQLExceptionpublic void rollback(java.sql.Savepoint savepoint)
throws java.sql.SQLException
rollback in interface java.sql.Connectionsavepoint - the savepointjava.sql.SQLExceptionpublic void releaseSavepoint(java.sql.Savepoint savepoint)
throws java.sql.SQLException
releaseSavepoint in interface java.sql.Connectionsavepoint - the savepoint to releasejava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)java.sql.SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementautoGeneratedKeys - Statement.RETURN_GENERATED_KEYS if generated keys should
be available for retrieval, Statement.NO_GENERATED_KEYS if
generated keys should not be availablejava.sql.SQLException - if the connection is closedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementcolumnIndexes - an array of column indexes indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if the connection is closedpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionsql - the SQL statementcolumnNames - an array of column names indicating the columns with generated
keys that should be returned from the inserted rowjava.sql.SQLException - if the connection is closedprotected void checkClosed()
DbException - if the connection or session is closedprotected void checkClosed(boolean write)
write - if the next operation is possibly writingDbException - if the connection or session is closedprotected void afterWriting()
public int getPowerOffCount()
public void setPowerOffCount(int count)
public void setExecutingStatement(java.sql.Statement stat)
public java.sql.Clob createClob()
throws java.sql.SQLException
createClob in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Blob createBlob()
throws java.sql.SQLException
createBlob in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.NClob createNClob()
throws java.sql.SQLException
createNClob in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.SQLXML createSQLXML()
throws java.sql.SQLException
createSQLXML in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Array createArrayOf(java.lang.String typeName,
java.lang.Object[] elements)
throws java.sql.SQLException
createArrayOf in interface java.sql.ConnectiontypeName - the type nameelements - the valuesjava.sql.SQLExceptionpublic java.sql.Struct createStruct(java.lang.String typeName,
java.lang.Object[] attributes)
throws java.sql.SQLException
createStruct in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean isValid(int timeout)
isValid in interface java.sql.Connectiontimeout - the number of seconds to wait for the database to respond
(ignored)public void setClientInfo(java.lang.String name,
java.lang.String value)
throws java.sql.SQLClientInfoException
setClientInfo in interface java.sql.Connectionname - the name of the propertyvalue - the valuejava.sql.SQLClientInfoExceptionpublic void setClientInfo(java.util.Properties properties)
throws java.sql.SQLClientInfoException
setClientInfo in interface java.sql.Connectionproperties - the properties (ignored)java.sql.SQLClientInfoExceptionpublic java.util.Properties getClientInfo()
throws java.sql.SQLException
getClientInfo in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getClientInfo(java.lang.String name)
throws java.sql.SQLException
getClientInfo in interface java.sql.Connectionname - the client info namejava.sql.SQLExceptionpublic <T> T unwrap(java.lang.Class<T> iface)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperiface - the classjava.sql.SQLExceptionpublic boolean isWrapperFor(java.lang.Class<?> iface)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperiface - the classjava.sql.SQLExceptionpublic Value createClob(java.io.Reader x, long length)
x - the readerlength - the length (if smaller or equal than 0, all data until the
end of file is read)public Value createBlob(java.io.InputStream x, long length)
x - the input streamlength - the length (if smaller or equal than 0, all data until the
end of file is read)public void setSchema(java.lang.String schema)
throws java.sql.SQLException
setSchema in interface java.sql.Connectionschema - the schema namejava.sql.SQLExceptionpublic java.lang.String getSchema()
throws java.sql.SQLException
getSchema in interface java.sql.Connectionjava.sql.SQLExceptionpublic void abort(java.util.concurrent.Executor executor)
abort in interface java.sql.Connectionexecutor - the executor used by this methodpublic void setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds)
setNetworkTimeout in interface java.sql.Connectionexecutor - the executor used by this methodmilliseconds - the TCP connection timeoutpublic int getNetworkTimeout()
getNetworkTimeout in interface java.sql.Connectionpublic java.lang.String toString()
toString in class java.lang.Objectpublic void setTraceLevel(int level)