|
com.im.commons.db 5.9.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.jdbc.datasource.AbstractDataSource
org.springframework.jdbc.datasource.AbstractDriverBasedDataSource
org.springframework.jdbc.datasource.DriverManagerDataSource
com.im.commons.db.datasource.BaseDataSource
public abstract class BaseDataSource
This is a base class for data sources. Specific DB support modules may provide its own DataSources with DB-specific options. The DataSource implements a connection pool and returns connections allocated from that pool. The close() method of those connections will only return the connection to the pool for reuse. Excess connections are closed. When a connection is returned to a thread, it is always returned to the thread. Those connection maintains a reference counter, so the thread properly returns connection to the pool just by calling close() on it. Current DIF code expects that dataSource.getConnection() will return the same Connection during the whole process, e.g. with respect to an active/opened transaction. The DataSource can be close()d, which closes all managed connection and detaches the connection pool. The next call to getConnection will allocate a new connection pool. It is NOT PERMITTED to change credentials or connection URL while a connection is active. All connections must be closed first, preferably by BaseDataSource.close().
| Field Summary |
|---|
| Fields inherited from class org.springframework.jdbc.datasource.AbstractDataSource |
|---|
logger |
| Constructor Summary | |
|---|---|
BaseDataSource()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
BaseDataSource |
clone()
Clone is overridden to copy over all visible properties, but JDK clone() is not used because only definition of the datasource not connection pools etc should be copied. |
void |
close()
Closes all connections and the object pool. |
protected ObjectPool |
createConnectionPool()
Written as an initializer, as it will be executed no matter which constructor will create the object PENDING P3: make these values configurable |
protected DataSource |
createDelegate(String url,
Properties props)
Will return a pooling delegate, constructing it from the current properties, if necessary. |
String |
getCatalog()
|
protected Connection |
getConnectionFromDriverManager(String url,
Properties properties)
|
DBType |
getDbType()
|
String |
getDriverClassName()
|
ObjectPoolFactory |
getObjectPoolFactory()
|
Properties |
getProperties()
|
String |
getSchema()
|
boolean |
isPrepareConnectionForCartridge()
Get the value of prepareConnectionForCartridge |
boolean |
isWrapperFor(Class iface)
|
protected void |
prepareNewConnection(Connection con)
|
void |
setCatalog(String catalog)
|
void |
setDbType(DBType dbType)
|
void |
setDriverClassName(String driverClassName)
|
void |
setObjectPoolFactory(ObjectPoolFactory objectPoolFactory)
|
void |
setPrepareConnectionForCartridge(boolean prepareConnectionForCartridge)
Set the value of prepareConnectionForCartridge |
void |
setProperties(Properties props)
|
void |
setSchema(String schema)
|
String |
toString()
|
Object |
unwrap(Class iface)
|
| Methods inherited from class org.springframework.jdbc.datasource.DriverManagerDataSource |
|---|
getConnectionFromDriver |
| Methods inherited from class org.springframework.jdbc.datasource.AbstractDriverBasedDataSource |
|---|
getConnection, getConnection, getConnectionFromDriver, getConnectionProperties, getPassword, getUrl, getUsername, setConnectionProperties, setPassword, setUrl, setUsername |
| Methods inherited from class org.springframework.jdbc.datasource.AbstractDataSource |
|---|
getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BaseDataSource()
| Method Detail |
|---|
public boolean isPrepareConnectionForCartridge()
public void setPrepareConnectionForCartridge(boolean prepareConnectionForCartridge)
prepareConnectionForCartridge - The new value of prepareConnectionForCartridgeprotected ObjectPool createConnectionPool()
public void afterPropertiesSet()
public ObjectPoolFactory getObjectPoolFactory()
public void setObjectPoolFactory(ObjectPoolFactory objectPoolFactory)
public String toString()
toString in class Object
public void close()
throws SQLException
close in interface ClosableDataSourceSQLExceptionpublic void setProperties(Properties props)
public Properties getProperties()
public String getSchema()
public void setSchema(String schema)
public String getCatalog()
public void setCatalog(String catalog)
protected DataSource createDelegate(String url,
Properties props)
protected void prepareNewConnection(Connection con)
protected Connection getConnectionFromDriverManager(String url,
Properties properties)
throws SQLException
getConnectionFromDriverManager in class DriverManagerDataSourceSQLExceptionpublic void setDriverClassName(String driverClassName)
setDriverClassName in class DriverManagerDataSourcepublic String getDriverClassName()
public BaseDataSource clone()
clone in class Object
public boolean isWrapperFor(Class iface)
throws SQLException
isWrapperFor in interface WrapperisWrapperFor in class AbstractDataSourceSQLException
public Object unwrap(Class iface)
throws SQLException
unwrap in interface Wrapperunwrap in class AbstractDataSourceSQLExceptionpublic DBType getDbType()
public void setDbType(DBType dbType)
|
com.im.commons.db 5.9.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||