public class DataSourceConnectionSource
extends com.j256.ormlite.support.BaseConnectionSource
implements com.j256.ormlite.support.ConnectionSource
DataSource that supports our ConnectionSource interface. This allows you to wrap other
multi-threaded, high-performance data sources, see Apache DBCP, CP30, or BoneCP.
NOTE: If you are using the Spring type wiring in Java, initialize() should be called after all of the
set methods. In Spring XML, init-method="initialize" should be used.
| Constructor and Description |
|---|
DataSourceConnectionSource()
Constructor for Spring type wiring if you are using the set methods.
|
DataSourceConnectionSource(DataSource dataSource,
com.j256.ormlite.db.DatabaseType databaseType)
Create a data source wrapper for a DataSource.
|
DataSourceConnectionSource(DataSource dataSource,
String databaseUrl)
Create a data source wrapper for a DataSource.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clearSpecialConnection(com.j256.ormlite.support.DatabaseConnection connection) |
void |
close()
This typically closes the connection source but because there is not a close() method on the
DataSource
(grrrr), this close method does _nothing_. |
void |
closeQuietly() |
com.j256.ormlite.db.DatabaseType |
getDatabaseType() |
com.j256.ormlite.support.DatabaseConnection |
getReadOnlyConnection(String tableName) |
com.j256.ormlite.support.DatabaseConnection |
getReadOnlyConnection(String tableName,
String username,
String password) |
com.j256.ormlite.support.DatabaseConnection |
getReadWriteConnection(String tableName) |
com.j256.ormlite.support.DatabaseConnection |
getReadWriteConnection(String tableName,
String username,
String password) |
void |
initialize()
Initialize the class after the setters have been called.
|
boolean |
isOpen(String tableName)
Unfortunately we cannot tell if the related data source has been closed so this just returns true.
|
boolean |
isSingleConnection(String tableName)
Return true if there is only one connection to the database.
|
void |
releaseConnection(com.j256.ormlite.support.DatabaseConnection connection) |
boolean |
saveSpecialConnection(com.j256.ormlite.support.DatabaseConnection connection) |
void |
setDatabaseType(com.j256.ormlite.db.DatabaseType databaseType) |
void |
setDatabaseUrl(String databaseUrl) |
void |
setDataSource(DataSource dataSource) |
clearSpecial, getSavedConnection, getSpecialConnection, isSavedConnection, isSingleConnection, saveSpecialpublic DataSourceConnectionSource()
public DataSourceConnectionSource(DataSource dataSource, String databaseUrl) throws SQLException
SQLException - If the driver associated with the database URL is not found in the classpath.public DataSourceConnectionSource(DataSource dataSource, com.j256.ormlite.db.DatabaseType databaseType) throws SQLException
DataSourceConnectionSource(DataSource, String) instead. If, however, you need to
force the class to use a specific DatabaseType then this constructor should be used.SQLException - If the driver associated with the database URL is not found in the classpath.public void initialize()
throws SQLException
SQLException - If the driver associated with the database URL is not found in the classpath.public com.j256.ormlite.support.DatabaseConnection getReadOnlyConnection(String tableName) throws SQLException
getReadOnlyConnection in interface com.j256.ormlite.support.ConnectionSourceSQLExceptionpublic com.j256.ormlite.support.DatabaseConnection getReadOnlyConnection(String tableName, String username, String password) throws SQLException
SQLExceptionpublic com.j256.ormlite.support.DatabaseConnection getReadWriteConnection(String tableName) throws SQLException
getReadWriteConnection in interface com.j256.ormlite.support.ConnectionSourceSQLExceptionpublic void releaseConnection(com.j256.ormlite.support.DatabaseConnection connection)
throws SQLException
releaseConnection in interface com.j256.ormlite.support.ConnectionSourceSQLExceptionpublic com.j256.ormlite.support.DatabaseConnection getReadWriteConnection(String tableName, String username, String password) throws SQLException
SQLExceptionpublic boolean saveSpecialConnection(com.j256.ormlite.support.DatabaseConnection connection)
throws SQLException
saveSpecialConnection in interface com.j256.ormlite.support.ConnectionSourceSQLExceptionpublic void clearSpecialConnection(com.j256.ormlite.support.DatabaseConnection connection)
clearSpecialConnection in interface com.j256.ormlite.support.ConnectionSourcepublic void close()
throws Exception
DataSource
(grrrr), this close method does _nothing_. You must close the underlying data-source yourself.close in interface AutoCloseableExceptionpublic void closeQuietly()
closeQuietly in interface com.j256.ormlite.support.ConnectionSourcepublic com.j256.ormlite.db.DatabaseType getDatabaseType()
getDatabaseType in interface com.j256.ormlite.support.ConnectionSourcepublic boolean isOpen(String tableName)
isOpen in interface com.j256.ormlite.support.ConnectionSourcepublic boolean isSingleConnection(String tableName)
NOTE: to test the data-source to see if it gives out multiple connections, we request two connections to see if they are different. I guess that's the best that we can do.
isSingleConnection in interface com.j256.ormlite.support.ConnectionSourcepublic void setDataSource(DataSource dataSource)
public void setDatabaseType(com.j256.ormlite.db.DatabaseType databaseType)
public void setDatabaseUrl(String databaseUrl)
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.