public class JdbcConnection extends TraceObject implements 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| 构造器和说明 |
|---|
JdbcConnection(ConnectionInfo ci,
boolean useBaseDir)
INTERNAL
|
JdbcConnection(JdbcConnection clone)
INTERNAL
|
JdbcConnection(SessionInterface session,
String user,
String url)
INTERNAL
|
JdbcConnection(String url,
Properties info)
INTERNAL
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
abort(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.
|
Array |
createArrayOf(String typeName,
Object[] elements)
[Not supported] Create a new empty Array object.
|
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.
|
NClob |
createNClob()
Create a new empty NClob object.
|
SQLXML |
createSQLXML()
[Not supported] Create a new empty SQLXML object.
|
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.
|
Struct |
createStruct(String typeName,
Object[] attributes)
[Not supported] Create a new empty Struct object.
|
boolean |
getAutoCommit()
Gets the current setting for auto commit.
|
String |
getCatalog()
Gets the current catalog name.
|
Properties |
getClientInfo()
Get the client properties.
|
String |
getClientInfo(String name)
Get a client property.
|
int |
getHoldability()
Returns the current result set holdability.
|
DatabaseMetaData |
getMetaData()
Gets the database meta data for this database.
|
int |
getNetworkTimeout()
[Not supported]
|
int |
getPowerOffCount()
INTERNAL
|
String |
getSchema()
Retrieves this current schema name for this connection.
|
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.
|
boolean |
isWrapperFor(Class<?> iface)
Checks if unwrap can return an object of this class.
|
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 |
setClientInfo(Properties properties)
Set the client properties.
|
void |
setClientInfo(String name,
String value)
Set a client property.
|
void |
setExecutingStatement(Statement stat)
INTERNAL
|
void |
setHoldability(int holdability)
Changes the current result set holdability.
|
void |
setNetworkTimeout(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.
|
Savepoint |
setSavepoint()
Creates a new unnamed savepoint.
|
Savepoint |
setSavepoint(String name)
Creates a new named savepoint.
|
void |
setSchema(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(Map<String,Class<?>> map)
[Partially supported] Sets the type map.
|
String |
toString()
INTERNAL
|
<T> T |
unwrap(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(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 在接口中 ConnectionSQLException - if the connection is closedpublic Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
createStatement 在接口中 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 在接口中 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 在接口中 Connectionsql - the SQL statementSQLException - if the connection is closedpublic DatabaseMetaData getMetaData() throws SQLException
getMetaData 在接口中 ConnectionSQLException - if the connection is closedpublic SessionInterface getSession()
public void close()
throws SQLException
close 在接口中 AutoCloseableclose 在接口中 ConnectionSQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws SQLException
setAutoCommit 在接口中 ConnectionautoCommit - true for auto commit on, false for offSQLException - if the connection is closedpublic boolean getAutoCommit()
throws SQLException
getAutoCommit 在接口中 ConnectionSQLException - if the connection is closedpublic void commit()
throws SQLException
commit 在接口中 ConnectionSQLException - if the connection is closedpublic void rollback()
throws SQLException
rollback 在接口中 ConnectionSQLException - if the connection is closedpublic boolean isClosed()
throws SQLException
isClosed 在接口中 ConnectionSQLExceptionpublic String nativeSQL(String sql) throws SQLException
nativeSQL 在接口中 Connectionsql - the SQL statement with or without JDBC escape sequencesSQLException - if the connection is closedpublic void setReadOnly(boolean readOnly)
throws SQLException
setReadOnly 在接口中 ConnectionreadOnly - ignoredSQLException - if the connection is closedpublic boolean isReadOnly()
throws SQLException
isReadOnly 在接口中 ConnectionSQLException - if the connection is closedpublic void setCatalog(String catalog) throws SQLException
setCatalog 在接口中 Connectioncatalog - ignoredSQLException - if the connection is closedpublic String getCatalog() throws SQLException
getCatalog 在接口中 ConnectionSQLException - if the connection is closedpublic SQLWarning getWarnings() throws SQLException
getWarnings 在接口中 ConnectionSQLExceptionpublic void clearWarnings()
throws SQLException
clearWarnings 在接口中 ConnectionSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
prepareStatement 在接口中 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 在接口中 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 getTransactionIsolation()
throws SQLException
getTransactionIsolation 在接口中 ConnectionSQLException - if the connection is closedpublic void setHoldability(int holdability)
throws SQLException
setHoldability 在接口中 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 在接口中 ConnectionSQLException - if the connection is closedpublic Map<String,Class<?>> getTypeMap() throws SQLException
getTypeMap 在接口中 ConnectionSQLException - if the connection is closedpublic void setTypeMap(Map<String,Class<?>> map) throws SQLException
setTypeMap 在接口中 ConnectionSQLExceptionpublic CallableStatement prepareCall(String sql) throws SQLException
prepareCall 在接口中 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 在接口中 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 在接口中 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 在接口中 ConnectionSQLExceptionpublic Savepoint setSavepoint(String name) throws SQLException
setSavepoint 在接口中 Connectionname - the savepoint nameSQLExceptionpublic void rollback(Savepoint savepoint) throws SQLException
rollback 在接口中 Connectionsavepoint - the savepointSQLExceptionpublic void releaseSavepoint(Savepoint savepoint) throws SQLException
releaseSavepoint 在接口中 Connectionsavepoint - the savepoint to releaseSQLExceptionpublic PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
prepareStatement 在接口中 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 在接口中 Connectionsql - the SQL statementautoGeneratedKeys - ignoredSQLException - if the connection is closedpublic PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
prepareStatement 在接口中 Connectionsql - the SQL statementcolumnIndexes - ignoredSQLException - if the connection is closedpublic PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
prepareStatement 在接口中 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 在接口中 ConnectionSQLExceptionpublic Blob createBlob() throws SQLException
createBlob 在接口中 ConnectionSQLExceptionpublic NClob createNClob() throws SQLException
createNClob 在接口中 ConnectionSQLExceptionpublic SQLXML createSQLXML() throws SQLException
createSQLXML 在接口中 ConnectionSQLExceptionpublic Array createArrayOf(String typeName, Object[] elements) throws SQLException
createArrayOf 在接口中 ConnectionSQLExceptionpublic Struct createStruct(String typeName, Object[] attributes) throws SQLException
createStruct 在接口中 ConnectionSQLExceptionpublic boolean isValid(int timeout)
isValid 在接口中 Connectiontimeout - the number of seconds to wait for the database to respond
(ignored)public void setClientInfo(String name, String value) throws SQLClientInfoException
setClientInfo 在接口中 Connectionname - the name of the propertyvalue - the valueSQLClientInfoExceptionpublic void setClientInfo(Properties properties) throws SQLClientInfoException
setClientInfo 在接口中 Connectionproperties - the properties (ignored)SQLClientInfoExceptionpublic Properties getClientInfo() throws SQLException
getClientInfo 在接口中 ConnectionSQLExceptionpublic String getClientInfo(String name) throws SQLException
getClientInfo 在接口中 Connectionname - the client info nameSQLExceptionpublic <T> T unwrap(Class<T> iface) throws SQLException
unwrap 在接口中 Wrapperiface - the classSQLExceptionpublic boolean isWrapperFor(Class<?> iface) throws SQLException
isWrapperFor 在接口中 Wrapperiface - the classSQLExceptionpublic 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 setSchema(String schema) throws SQLException
setSchema 在接口中 Connectionschema - the schema nameSQLExceptionpublic String getSchema() throws SQLException
getSchema 在接口中 ConnectionSQLExceptionpublic void abort(Executor executor)
abort 在接口中 Connectionexecutor - the executor used by this methodpublic void setNetworkTimeout(Executor executor, int milliseconds)
setNetworkTimeout 在接口中 Connectionexecutor - the executor used by this methodmilliseconds - the TCP connection timeoutpublic int getNetworkTimeout()
getNetworkTimeout 在接口中 Connectionpublic void setTraceLevel(int level)
Copyright © 2017. All rights reserved.