public class WrappedConnectionSource extends Object implements ConnectionSource
Modifier and Type | Field and Description |
---|---|
protected ConnectionSource |
cs |
protected static Logger |
logger |
protected boolean |
nextForceOkay |
Constructor and Description |
---|
WrappedConnectionSource(ConnectionSource cs) |
Modifier and Type | Method and Description |
---|---|
void |
clearSpecialConnection(DatabaseConnection connection)
Clear the saved connection.
|
void |
close() |
void |
closeQuietly()
Close any outstanding database connections.
|
void |
forceOkay()
Used if we want to forcefully close a connection source without throwing errors.
|
int |
getConnectionCount() |
DatabaseType |
getDatabaseType()
Return the DatabaseTypre associated with this connection.
|
DatabaseConnection |
getReadOnlyConnection(String tableName)
Return a database connection suitable for read-only operations.
|
DatabaseConnection |
getReadWriteConnection(String tableName)
Return a database connection suitable for read or write operations.
|
DatabaseConnection |
getSpecialConnection(String tableName)
Return the currently saved connection or null if none.
|
boolean |
isEverythingClosed() |
boolean |
isOpen(String tableName)
Return true if the connection source is open.
|
boolean |
isSingleConnection(String tableName)
Return true if there is only one connection to the database being used by this connection-sourse.
|
void |
releaseConnection(DatabaseConnection proxy)
Release a database connection previously returned by
ConnectionSource.getReadOnlyConnection(String) or
ConnectionSource.getReadWriteConnection(String) . |
boolean |
saveSpecialConnection(DatabaseConnection connection)
Save this connection and return it for all calls to
ConnectionSource.getReadOnlyConnection(String) and
ConnectionSource.getReadWriteConnection(String) unless the ConnectionSource.clearSpecialConnection(DatabaseConnection) method is
called, all This is used by the transaction mechanism since since all operations within a transaction must
operate on the same connection. |
void |
setDatabaseType(DatabaseType databaseType) |
protected static final Logger logger
protected final ConnectionSource cs
protected boolean nextForceOkay
public WrappedConnectionSource(ConnectionSource cs)
public DatabaseConnection getReadOnlyConnection(String tableName) throws SQLException
ConnectionSource
ConnectionSource.releaseConnection(DatabaseConnection)
.getReadOnlyConnection
in interface ConnectionSource
SQLException
public DatabaseConnection getReadWriteConnection(String tableName) throws SQLException
ConnectionSource
ConnectionSource.releaseConnection(DatabaseConnection)
.getReadWriteConnection
in interface ConnectionSource
SQLException
public void releaseConnection(DatabaseConnection proxy) throws SQLException
ConnectionSource
ConnectionSource.getReadOnlyConnection(String)
or
ConnectionSource.getReadWriteConnection(String)
.releaseConnection
in interface ConnectionSource
SQLException
public void close() throws Exception
close
in interface AutoCloseable
Exception
public void closeQuietly()
ConnectionSource
closeQuietly
in interface ConnectionSource
public void forceOkay()
public boolean isEverythingClosed()
public boolean saveSpecialConnection(DatabaseConnection connection) throws SQLException
ConnectionSource
ConnectionSource.getReadOnlyConnection(String)
and
ConnectionSource.getReadWriteConnection(String)
unless the ConnectionSource.clearSpecialConnection(DatabaseConnection)
method is
called, all This is used by the transaction mechanism since since all operations within a transaction must
operate on the same connection. It is also used by the Android code during initialization.
NOTE: This should be a read-write connection since transactions and Android need it to be so.
NOTE: Saving a connection is usually accomplished using ThreadLocals so multiple threads should not be using connections in this scenario.
saveSpecialConnection
in interface ConnectionSource
SQLException
public void clearSpecialConnection(DatabaseConnection connection)
ConnectionSource
clearSpecialConnection
in interface ConnectionSource
public DatabaseConnection getSpecialConnection(String tableName)
ConnectionSource
getSpecialConnection
in interface ConnectionSource
public DatabaseType getDatabaseType()
ConnectionSource
getDatabaseType
in interface ConnectionSource
public boolean isOpen(String tableName)
ConnectionSource
AutoCloseable.close()
has been called, this should return false.isOpen
in interface ConnectionSource
public boolean isSingleConnection(String tableName)
ConnectionSource
isSingleConnection
in interface ConnectionSource
public void setDatabaseType(DatabaseType databaseType)
public int getConnectionCount()
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.