java.lang.AutoCloseable, java.sql.Connection, java.sql.WrapperCachingLogicalConnectionpublic class LogicalConnection
extends java.lang.Object
implements java.sql.Connection
All methods of the Connection interface are forwarded to the
underlying physical connection, except for close() and
isClosed(). When a physical connection is wrapped, it is non-null,
when the logical connection is closed, the wrapped physical connection is
always set to null.
Both the finalizer and the close-methods will always set the
physical connection to null. After the physical connection has been
nulled out, only the PooledConnection instance will maintain a
handle to the physical connection.
| Modifier and Type | Field | Description |
|---|---|---|
private LogicalDatabaseMetaData |
logicalDatabaseMetaData |
Logical database metadata object created on demand and then cached.
|
(package private) ClientConnection |
physicalConnection_ |
Underlying physical connection for this logical connection.
|
private ClientPooledConnection |
pooledConnection_ |
| Constructor | Description |
|---|---|
LogicalConnection(ClientConnection physicalConnection,
ClientPooledConnection pooledConnection) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
abort(java.util.concurrent.Executor executor) |
|
protected void |
checkForNullPhysicalConnection() |
Verifies that there is an underlying physical connection for this
logical connection.
|
void |
clearWarnings() |
|
void |
close() |
|
void |
closeWithoutRecyclingToPool() |
|
void |
commit() |
|
java.sql.Array |
createArrayOf(java.lang.String typeName,
java.lang.Object[] elements) |
|
java.sql.Blob |
createBlob() |
|
java.sql.Clob |
createClob() |
|
java.sql.NClob |
createNClob() |
|
java.sql.SQLXML |
createSQLXML() |
|
java.sql.Statement |
createStatement() |
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
|
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
|
java.sql.Struct |
createStruct(java.lang.String typeName,
java.lang.Object[] attributes) |
|
protected void |
finalize() |
|
boolean |
getAutoCommit() |
|
java.lang.String |
getCatalog() |
|
java.util.Properties |
getClientInfo() |
getClientInfo forwards to
physicalConnection_. |
java.lang.String |
getClientInfo(java.lang.String name) |
getClientInfo forwards to
physicalConnection_. |
int |
getHoldability() |
|
java.sql.DatabaseMetaData |
getMetaData() |
Retrieves a
DatabaseMetaData object that contains metadata about
the database to which this Connection object represents a
connection. |
int |
getNetworkTimeout() |
|
(package private) java.sql.DatabaseMetaData |
getRealMetaDataObject() |
Returns the real underlying database metadata object.
|
java.lang.String |
getSchema() |
Get the name of the current schema.
|
int |
getServerVersion() |
|
int |
getTransactionID() |
Returns the client-side transaction id from am.Connection.
|
int |
getTransactionIsolation() |
|
java.util.Map<java.lang.String,java.lang.Class<?>> |
getTypeMap() |
|
java.sql.SQLWarning |
getWarnings() |
|
boolean |
isClosed() |
|
boolean |
isReadOnly() |
|
boolean |
isValid(int timeout) |
Checks if the connection has not been closed and is still valid.
|
boolean |
isWrapperFor(java.lang.Class<?> interfaces) |
|
java.lang.String |
nativeSQL(java.lang.String sql) |
|
protected LogicalDatabaseMetaData |
newLogicalDatabaseMetaData() |
Returns a newly created logical database metadata object.
|
(package private) void |
notifyException(java.sql.SQLException sqle) |
Notifies listeners about exceptions of session level severity or higher.
|
void |
nullPhysicalConnection() |
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql) |
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
|
java.sql.CallableStatement |
prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int autoGeneratedKeys) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int[] columnIndexes) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
|
java.sql.PreparedStatement |
prepareStatement(java.lang.String sql,
java.lang.String[] columnNames) |
|
void |
releaseSavepoint(java.sql.Savepoint savepoint) |
|
void |
rollback() |
|
void |
rollback(java.sql.Savepoint savepoint) |
|
void |
setAutoCommit(boolean autoCommit) |
|
void |
setCatalog(java.lang.String catalog) |
|
void |
setClientInfo(java.lang.String name,
java.lang.String value) |
setClientInfo forwards to
physicalConnection_. |
void |
setClientInfo(java.util.Properties properties) |
setClientInfo forwards to
physicalConnection_. |
void |
setHoldability(int holdability) |
|
void |
setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds) |
|
void |
setReadOnly(boolean readOnly) |
|
java.sql.Savepoint |
setSavepoint() |
|
java.sql.Savepoint |
setSavepoint(java.lang.String name) |
|
void |
setSchema(java.lang.String schemaName) |
Set the default schema for the Connection.
|
void |
setTransactionIsolation(int level) |
|
void |
setTypeMap(java.util.Map map) |
|
<T> T |
unwrap(java.lang.Class<T> interfaces) |
ClientConnection physicalConnection_
Set to null when this logical connection is closed.
private ClientPooledConnection pooledConnection_
private LogicalDatabaseMetaData logicalDatabaseMetaData
public LogicalConnection(ClientConnection physicalConnection, ClientPooledConnection pooledConnection) throws SqlException
SqlExceptionprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwablepublic void nullPhysicalConnection()
public void close()
throws java.sql.SQLException
close in interface java.lang.AutoCloseableclose in interface java.sql.Connectionjava.sql.SQLExceptionpublic void closeWithoutRecyclingToPool()
throws SqlException
SqlExceptionpublic boolean isClosed()
throws java.sql.SQLException
isClosed in interface java.sql.Connectionjava.sql.SQLExceptionprotected final void checkForNullPhysicalConnection()
throws java.sql.SQLException
If the physical connection has been nulled out it means that this logical connection has been closed.
java.sql.SQLException - if this logical connection has been closedfinal void notifyException(java.sql.SQLException sqle)
The exception, even if the severity is sufficiently high, is ignored if
the underlying physical connection has been nulled out. Otherwise a
connectionErrorOccurred-event is sent to all the registered
listeners.
sqle - the cause of the notificationpublic java.sql.Statement createStatement()
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String nativeSQL(java.lang.String sql)
throws java.sql.SQLException
nativeSQL in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
setAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean getAutoCommit()
throws java.sql.SQLException
getAutoCommit in interface java.sql.Connectionjava.sql.SQLExceptionpublic void commit()
throws java.sql.SQLException
commit in interface java.sql.Connectionjava.sql.SQLExceptionpublic void rollback()
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setTransactionIsolation(int level)
throws java.sql.SQLException
setTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getTransactionIsolation()
throws java.sql.SQLException
getTransactionIsolation in interface java.sql.Connectionjava.sql.SQLExceptionpublic 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.DatabaseMetaData getMetaData()
throws java.sql.SQLException
DatabaseMetaData object that contains metadata about
the database to which this Connection object represents a
connection.
The database metadata object is logical in the sense that it has the
same lifetime as the logical connection. If the logical connection is
closed, the underlying physical connection will not be accessed to
obtain metadata, even if it is still open. Also, the reference to the
logical connection instead of the underlying physical connection will be
returned by LogicalDatabaseMetaData.getConnection().
getMetaData in interface java.sql.Connectionjava.sql.SQLException - if an error occursprotected LogicalDatabaseMetaData newLogicalDatabaseMetaData() throws java.sql.SQLException
Subclasses should override this method to return an instance of the correct implementation class of the logical metadata object.
java.sql.SQLExceptionfinal java.sql.DatabaseMetaData getRealMetaDataObject()
throws java.sql.SQLException
java.sql.SQLException - if the logical connection has been closedpublic void setReadOnly(boolean readOnly)
throws java.sql.SQLException
setReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic boolean isReadOnly()
throws java.sql.SQLException
isReadOnly in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setCatalog(java.lang.String catalog)
throws java.sql.SQLException
setCatalog in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.lang.String getCatalog()
throws java.sql.SQLException
getCatalog in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
createStatement 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.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap()
throws java.sql.SQLException
getTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setTypeMap(java.util.Map map)
throws java.sql.SQLException
setTypeMap in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.Statement createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
createStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.CallableStatement prepareCall(java.lang.String sql,
int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws java.sql.SQLException
prepareCall in interface java.sql.Connectionjava.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.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int autoGeneratedKeys)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
int[] columnIndexes)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.sql.PreparedStatement prepareStatement(java.lang.String sql,
java.lang.String[] columnNames)
throws java.sql.SQLException
prepareStatement in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setHoldability(int holdability)
throws java.sql.SQLException
setHoldability in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getHoldability()
throws java.sql.SQLException
getHoldability in interface java.sql.Connectionjava.sql.SQLExceptionpublic 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.Connectionjava.sql.SQLExceptionpublic void rollback(java.sql.Savepoint savepoint)
throws java.sql.SQLException
rollback in interface java.sql.Connectionjava.sql.SQLExceptionpublic void releaseSavepoint(java.sql.Savepoint savepoint)
throws java.sql.SQLException
releaseSavepoint in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getTransactionID()
NOTE: This method was added for testing purposes. Avoid use in production code if possible.
public int getServerVersion()
public java.sql.Array createArrayOf(java.lang.String typeName,
java.lang.Object[] elements)
throws java.sql.SQLException
createArrayOf 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.Clob createClob()
throws java.sql.SQLException
createClob 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.Struct createStruct(java.lang.String typeName,
java.lang.Object[] attributes)
throws java.sql.SQLException
createStruct in interface java.sql.Connectionjava.sql.SQLExceptionpublic java.util.Properties getClientInfo()
throws java.sql.SQLException
getClientInfo forwards to
physicalConnection_.
getClientInfo always returns an empty
Properties object since Derby doesn't support
ClientInfoProperties.getClientInfo in interface java.sql.ConnectionProperties objectjava.sql.SQLException - if an error occurspublic java.lang.String getClientInfo(java.lang.String name)
throws java.sql.SQLException
getClientInfo forwards to
physicalConnection_. Always returns a null
String since Derby does not support
ClientInfoProperties.getClientInfo in interface java.sql.Connectionname - a property key to get StringStringjava.sql.SQLException - if an error occurspublic boolean isValid(int timeout)
throws java.sql.SQLException
isValid in interface java.sql.Connectiontimeout - The time in seconds to wait for the database
operation used to validate the connection to complete. If the
timeout period expires before the operation completes, this
method returns false. A value of 0 indicates a timeout is not
applied to the database operation.java.sql.SQLException - if the call on the physical connection throws an
exception.public boolean isWrapperFor(java.lang.Class<?> interfaces)
throws java.sql.SQLException
isWrapperFor in interface java.sql.Wrapperjava.sql.SQLExceptionpublic void setClientInfo(java.util.Properties properties)
throws java.sql.SQLClientInfoException
setClientInfo forwards to
physicalConnection_.setClientInfo in interface java.sql.Connectionproperties - a Properties object with the
properties to setjava.sql.SQLClientInfoException - if an error occurspublic void setClientInfo(java.lang.String name,
java.lang.String value)
throws java.sql.SQLClientInfoException
setClientInfo forwards to
physicalConnection_.setClientInfo in interface java.sql.Connectionname - a property key Stringvalue - a property value Stringjava.sql.SQLClientInfoException - if an error occurspublic <T> T unwrap(java.lang.Class<T> interfaces)
throws java.sql.SQLException
unwrap in interface java.sql.Wrapperjava.sql.SQLExceptionpublic java.lang.String getSchema()
throws java.sql.SQLException
getSchema in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setSchema(java.lang.String schemaName)
throws java.sql.SQLException
setSchema in interface java.sql.Connectionjava.sql.SQLExceptionpublic void abort(java.util.concurrent.Executor executor)
throws java.sql.SQLException
abort in interface java.sql.Connectionjava.sql.SQLExceptionpublic int getNetworkTimeout()
throws java.sql.SQLException
getNetworkTimeout in interface java.sql.Connectionjava.sql.SQLExceptionpublic void setNetworkTimeout(java.util.concurrent.Executor executor,
int milliseconds)
throws java.sql.SQLException
setNetworkTimeout in interface java.sql.Connectionjava.sql.SQLExceptionApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.