public 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 and Description |
---|---|
private LogicalDatabaseMetaData |
logicalDatabaseMetaData
Logical database metadata object created on demand and then cached.
|
(package private) Connection |
physicalConnection_
Underlying physical connection for this logical connection.
|
private ClientPooledConnection |
pooledConnection_ |
Constructor and Description |
---|
LogicalConnection(Connection physicalConnection,
ClientPooledConnection pooledConnection) |
Modifier and Type | Method and Description |
---|---|
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.Statement |
createStatement() |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency) |
java.sql.Statement |
createStatement(int resultSetType,
int resultSetConcurrency,
int resultSetHoldability) |
protected void |
finalize() |
boolean |
getAutoCommit() |
java.lang.String |
getCatalog() |
int |
getHoldability() |
java.sql.DatabaseMetaData |
getMetaData()
Retrieves a
DatabaseMetaData object that contains metadata about
the database to which this Connection object represents a
connection. |
(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() |
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) |
PreparedStatement |
preparePositionedUpdateStatement(java.lang.String sql,
Section querySection) |
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 |
setHoldability(int holdability) |
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) |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Connection physicalConnection_
Set to null
when this logical connection is closed.
private ClientPooledConnection pooledConnection_
private LogicalDatabaseMetaData logicalDatabaseMetaData
public LogicalConnection(Connection physicalConnection, ClientPooledConnection pooledConnection) throws SqlException
SqlException
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void nullPhysicalConnection()
public void close() throws java.sql.SQLException
close
in interface java.lang.AutoCloseable
close
in interface java.sql.Connection
java.sql.SQLException
public void closeWithoutRecyclingToPool() throws SqlException
SqlException
public boolean isClosed() throws java.sql.SQLException
isClosed
in interface java.sql.Connection
java.sql.SQLException
protected 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.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public PreparedStatement preparePositionedUpdateStatement(java.lang.String sql, Section querySection) throws SqlException
SqlException
public java.sql.CallableStatement prepareCall(java.lang.String sql) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String nativeSQL(java.lang.String sql) throws java.sql.SQLException
nativeSQL
in interface java.sql.Connection
java.sql.SQLException
public void setAutoCommit(boolean autoCommit) throws java.sql.SQLException
setAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public boolean getAutoCommit() throws java.sql.SQLException
getAutoCommit
in interface java.sql.Connection
java.sql.SQLException
public void commit() throws java.sql.SQLException
commit
in interface java.sql.Connection
java.sql.SQLException
public void rollback() throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
public void setTransactionIsolation(int level) throws java.sql.SQLException
setTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public int getTransactionIsolation() throws java.sql.SQLException
getTransactionIsolation
in interface java.sql.Connection
java.sql.SQLException
public java.sql.SQLWarning getWarnings() throws java.sql.SQLException
getWarnings
in interface java.sql.Connection
java.sql.SQLException
public void clearWarnings() throws java.sql.SQLException
clearWarnings
in interface java.sql.Connection
java.sql.SQLException
public 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.Connection
java.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.SQLException
final 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.Connection
java.sql.SQLException
public boolean isReadOnly() throws java.sql.SQLException
isReadOnly
in interface java.sql.Connection
java.sql.SQLException
public void setCatalog(java.lang.String catalog) throws java.sql.SQLException
setCatalog
in interface java.sql.Connection
java.sql.SQLException
public java.lang.String getCatalog() throws java.sql.SQLException
getCatalog
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.util.Map<java.lang.String,java.lang.Class<?>> getTypeMap() throws java.sql.SQLException
getTypeMap
in interface java.sql.Connection
java.sql.SQLException
public void setTypeMap(java.util.Map map) throws java.sql.SQLException
setTypeMap
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
createStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.CallableStatement prepareCall(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
prepareCall
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int autoGeneratedKeys) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, int[] columnIndexes) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public java.sql.PreparedStatement prepareStatement(java.lang.String sql, java.lang.String[] columnNames) throws java.sql.SQLException
prepareStatement
in interface java.sql.Connection
java.sql.SQLException
public void setHoldability(int holdability) throws java.sql.SQLException
setHoldability
in interface java.sql.Connection
java.sql.SQLException
public int getHoldability() throws java.sql.SQLException
getHoldability
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint() throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public java.sql.Savepoint setSavepoint(java.lang.String name) throws java.sql.SQLException
setSavepoint
in interface java.sql.Connection
java.sql.SQLException
public void rollback(java.sql.Savepoint savepoint) throws java.sql.SQLException
rollback
in interface java.sql.Connection
java.sql.SQLException
public void releaseSavepoint(java.sql.Savepoint savepoint) throws java.sql.SQLException
releaseSavepoint
in interface java.sql.Connection
java.sql.SQLException
public int getTransactionID()
NOTE: This method was added for testing purposes. Avoid use in production code if possible.
public int getServerVersion()
public java.lang.String getSchema() throws java.sql.SQLException
getSchema
in interface java.sql.Connection
java.sql.SQLException
public void setSchema(java.lang.String schemaName) throws java.sql.SQLException
setSchema
in interface java.sql.Connection
java.sql.SQLException
Apache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.