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, waitConnection physicalConnection_
Set to null when this logical connection is closed.
private ClientPooledConnection pooledConnection_
private LogicalDatabaseMetaData logicalDatabaseMetaData
public LogicalConnection(Connection 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 PreparedStatement preparePositionedUpdateStatement(java.lang.String sql, Section querySection) throws SqlException
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.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.SQLExceptionApache Derby V10.10 Internals - Copyright © 2004,2014 The Apache Software Foundation. All Rights Reserved.