public interface ConnectionSource extends AutoCloseable
Modifier and Type | Method and Description |
---|---|
void |
clearSpecialConnection(DatabaseConnection connection)
Clear the saved connection.
|
void |
closeQuietly()
Close any outstanding database connections.
|
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 |
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 connection)
Release a database connection previously returned by
getReadOnlyConnection(String) or
getReadWriteConnection(String) . |
boolean |
saveSpecialConnection(DatabaseConnection connection)
Save this connection and return it for all calls to
getReadOnlyConnection(String) and
getReadWriteConnection(String) unless the 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. |
close
DatabaseConnection getReadOnlyConnection(String tableName) throws SQLException
releaseConnection(DatabaseConnection)
.SQLException
DatabaseConnection getReadWriteConnection(String tableName) throws SQLException
releaseConnection(DatabaseConnection)
.SQLException
void releaseConnection(DatabaseConnection connection) throws SQLException
getReadOnlyConnection(String)
or
getReadWriteConnection(String)
.SQLException
boolean saveSpecialConnection(DatabaseConnection connection) throws SQLException
getReadOnlyConnection(String)
and
getReadWriteConnection(String)
unless the 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.
SQLException
void clearSpecialConnection(DatabaseConnection connection)
DatabaseConnection getSpecialConnection(String tableName)
void closeQuietly()
DatabaseType getDatabaseType()
boolean isOpen(String tableName)
AutoCloseable.close()
has been called, this should return false.boolean isSingleConnection(String tableName)
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.