public class JdbcConnection extends TraceObject implements Connection
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, SQL_EXCEPTION, STATEMENT, XA_DATA_SOURCE, XA_RESOURCE, XIDTRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE| Constructor and Description |
|---|
JdbcConnection(ConnectionInfo ci,
boolean useBaseDir)
INTERNAL
|
JdbcConnection(JdbcConnection clone)
INTERNAL
|
JdbcConnection(SessionInterface session,
String user,
String url)
INTERNAL
|
JdbcConnection(String url,
Properties info)
INTERNAL
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
Blob |
createBlob()
Create a new empty Blob object.
|
Value |
createBlob(InputStream x,
long length)
Create a Blob value from this input stream.
|
Clob |
createClob()
Create a new empty Clob object.
|
Value |
createClob(Reader x,
long length)
Create a Clob value from this reader.
|
Statement |
createStatement()
Creates a new statement.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency)
Creates a statement with the specified result set type and concurrency.
|
Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a statement with the specified result set type, concurrency, and
holdability.
|
boolean |
getAutoCommit()
Gets the current setting for auto commit.
|
String |
getCatalog()
Gets the current catalog name.
|
int |
getHoldability()
Returns the current result set holdability.
|
DatabaseMetaData |
getMetaData()
Gets the database meta data for this database.
|
int |
getPowerOffCount()
INTERNAL
|
int |
getQueryTimeout()
INTERNAL
|
SessionInterface |
getSession()
INTERNAL
|
int |
getTransactionIsolation()
Returns the current transaction isolation level.
|
Map<String,Class<?>> |
getTypeMap()
Gets the type map.
|
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.
|
String |
nativeSQL(String sql)
Translates a SQL statement into the database grammar.
|
CallableStatement |
prepareCall(String sql)
Creates a new callable statement.
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a callable statement with the specified result set type and
concurrency.
|
CallableStatement |
prepareCall(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a callable statement with the specified result set type,
concurrency, and holdability.
|
PreparedStatement |
prepareStatement(String sql)
Creates a new prepared statement.
|
PreparedStatement |
prepareStatement(String sql,
int autoGeneratedKeys)
Creates a new prepared statement.
|
PreparedStatement |
prepareStatement(String sql,
int[] columnIndexes)
Creates a new prepared statement.
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency)
Creates a prepared statement with the specified result set type and
concurrency.
|
PreparedStatement |
prepareStatement(String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
Creates a prepared statement with the specified result set type,
concurrency, and holdability.
|
PreparedStatement |
prepareStatement(String sql,
String[] columnNames)
Creates a new prepared statement.
|
void |
releaseSavepoint(Savepoint savepoint)
Releases a savepoint.
|
void |
rollback()
Rolls back the current transaction.
|
void |
rollback(Savepoint savepoint)
Rolls back to a savepoint.
|
void |
setAutoCommit(boolean autoCommit)
Switches auto commit on or off.
|
void |
setCatalog(String catalog)
Set the default catalog name.
|
void |
setExecutingStatement(Statement stat)
INTERNAL
|
void |
setHoldability(int holdability)
Changes the current result set holdability.
|
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.
|
Savepoint |
setSavepoint()
Creates a new unnamed savepoint.
|
Savepoint |
setSavepoint(String name)
Creates a new named savepoint.
|
void |
setTraceLevel(int level)
INTERNAL
|
void |
setTransactionIsolation(int level)
Changes the current transaction isolation level.
|
void |
setTypeMap(Map<String,Class<?>> map)
[Partially supported] Sets the type map.
|
String |
toString()
INTERNAL
|
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTrace, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupportedclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitabort, createArrayOf, createNClob, createSQLXML, createStruct, getClientInfo, getClientInfo, getNetworkTimeout, getSchema, setClientInfo, setClientInfo, setNetworkTimeout, setSchemaisWrapperFor, unwrappublic JdbcConnection(String url, Properties info) throws SQLException
SQLExceptionpublic JdbcConnection(ConnectionInfo ci, boolean useBaseDir) throws SQLException
SQLExceptionpublic JdbcConnection(JdbcConnection clone)
public JdbcConnection(SessionInterface session, String user, String url)
public Statement createStatement() throws SQLException
createStatement in interface ConnectionSQLException - if the connection is closedpublic Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement in interface ConnectionresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)SQLException - if the connection is closed or the result set type or
concurrency are not supportedpublic Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
createStatement in interface ConnectionresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic PreparedStatement prepareStatement(String sql) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementSQLException - if the connection is closedpublic DatabaseMetaData getMetaData() throws SQLException
getMetaData in interface ConnectionSQLException - if the connection is closedpublic SessionInterface getSession()
public void close()
throws SQLException
close in interface AutoCloseableclose in interface ConnectionSQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit in interface ConnectionautoCommit - true for auto commit on, false for offSQLException - if the connection is closedpublic boolean getAutoCommit()
throws SQLException
getAutoCommit in interface ConnectionSQLException - if the connection is closedpublic void commit()
throws SQLException
commit in interface ConnectionSQLException - if the connection is closedpublic void rollback()
throws SQLException
rollback in interface ConnectionSQLException - if the connection is closedpublic boolean isClosed()
throws SQLException
isClosed in interface ConnectionSQLExceptionpublic String nativeSQL(String sql) throws SQLException
nativeSQL in interface Connectionsql - the SQL statement with or without JDBC escape sequencesSQLException - if the connection is closedpublic void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly in interface ConnectionreadOnly - ignoredSQLException - if the connection is closedpublic boolean isReadOnly()
throws SQLException
isReadOnly in interface ConnectionSQLException - if the connection is closedpublic void setCatalog(String catalog) throws SQLException
setCatalog in interface Connectioncatalog - ignoredSQLException - if the connection is closedpublic String getCatalog() throws SQLException
getCatalog in interface ConnectionSQLException - if the connection is closedpublic SQLWarning getWarnings() throws SQLException
getWarnings in interface ConnectionSQLExceptionpublic void clearWarnings()
throws SQLException
clearWarnings in interface ConnectionSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)SQLException - if the connection is closed or the result set type or
concurrency are not supportedpublic void setTransactionIsolation(int level)
throws SQLException
setTransactionIsolation in interface Connectionlevel - the new transaction isolation level:
Connection.TRANSACTION_READ_UNCOMMITTED,
Connection.TRANSACTION_READ_COMMITTED, or
Connection.TRANSACTION_SERIALIZABLESQLException - if the connection is closed or the isolation level
is not supportedpublic void setQueryTimeout(int seconds)
throws SQLException
SQLExceptionpublic int getQueryTimeout()
throws SQLException
SQLExceptionpublic int getTransactionIsolation()
throws SQLException
getTransactionIsolation in interface ConnectionSQLException - if the connection is closedpublic void setHoldability(int holdability)
throws SQLException
setHoldability in interface Connectionholdability - ResultSet.HOLD_CURSORS_OVER_COMMIT or
ResultSet.CLOSE_CURSORS_AT_COMMIT;SQLException - if the connection is closed or the holdability is not
supportedpublic int getHoldability()
throws SQLException
getHoldability in interface ConnectionSQLException - if the connection is closedpublic Map<String,Class<?>> getTypeMap() throws SQLException
getTypeMap in interface ConnectionSQLException - if the connection is closedpublic void setTypeMap(Map<String,Class<?>> map) throws SQLException
setTypeMap in interface ConnectionSQLExceptionpublic CallableStatement prepareCall(String sql) throws SQLException
prepareCall in interface Connectionsql - the SQL statementSQLException - if the connection is closed or the statement is not validpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareCall in interface Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)SQLException - if the connection is closed or the result set type or
concurrency are not supportedpublic CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareCall in interface Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic Savepoint setSavepoint() throws SQLException
setSavepoint in interface ConnectionSQLExceptionpublic Savepoint setSavepoint(String name) throws SQLException
setSavepoint in interface Connectionname - the savepoint nameSQLExceptionpublic void rollback(Savepoint savepoint) throws SQLException
rollback in interface Connectionsavepoint - the savepointSQLExceptionpublic void releaseSavepoint(Savepoint savepoint) throws SQLException
releaseSavepoint in interface Connectionsavepoint - the savepoint to releaseSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementresultSetType - the result set type (ResultSet.TYPE_*)resultSetConcurrency - the concurrency (ResultSet.CONCUR_*)resultSetHoldability - the holdability (ResultSet.HOLD* / CLOSE*)SQLException - if the connection is closed or the result set type,
concurrency, or holdability are not supportedpublic PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementautoGeneratedKeys - ignoredSQLException - if the connection is closedpublic PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementcolumnIndexes - ignoredSQLException - if the connection is closedpublic PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
prepareStatement in interface Connectionsql - the SQL statementcolumnNames - ignoredSQLException - 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(Statement stat)
public Clob createClob() throws SQLException
createClob in interface ConnectionSQLExceptionpublic Blob createBlob() throws SQLException
createBlob in interface ConnectionSQLExceptionpublic boolean isValid(int timeout)
isValid in interface Connectiontimeout - the number of seconds to wait for the database to respond
(ignored)public Value createClob(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(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 setTraceLevel(int level)
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.