com.nec.tdd.tools.dbMapper
Class BasicDataSource
java.lang.Object
|
+--com.nec.tdd.tools.dbMapper.BasicDataSource
- All Implemented Interfaces:
- DataSource
- public class BasicDataSource
- extends java.lang.Object
- implements DataSource
Basic database connection manager implementation provided by database
module.
The getConnection method simply creates a new JDBC
connection each time. After finishing database task, the calling class
should release the acquired DBConnection object by calling releaseConnection
method (which simply closes the JDBC connection & related resources).
As opening a new JDBC connection is a costly operation, this connection
manager is suitable for only those applications (DBInterface objects)
where database operations are infrequent or for one-time use only.
- See Also:
ConnectionPoolDataSource
Constructor Summary |
BasicDataSource(DBConnectionInfo dbInfoBean)
Constructs a BasicDataSource object with given database connection
information. |
BasicDataSource(DBConnectionInfo dbInfoBean,
int maxConnections)
Constructs a BasicDataSource object with given database connection
information and upper bound on number of connections opened by at a time by
this connection manager. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
BasicDataSource
public BasicDataSource(DBConnectionInfo dbInfoBean)
throws java.lang.Exception
- Constructs a BasicDataSource object with given database connection
information.
- Parameters:
dbInfoBean
- database connection information (JDBC url,
driver name, user & password).- Throws:
java.lang.Exception
- if a database access error occurs.
BasicDataSource
public BasicDataSource(DBConnectionInfo dbInfoBean,
int maxConnections)
throws java.lang.Exception
- Constructs a BasicDataSource object with given database connection
information and upper bound on number of connections opened by at a time by
this connection manager.
- Parameters:
dbInfoBean
- database connection information (JDBC url,
driver name, user & password).maxConnections
- maximum number of connections opened at a time by
this connection manager. A <=0 value is treated as
unlimited connections.- Throws:
java.lang.Exception
- if a database access error occurs.
getConnection
public DBConnection getConnection()
- Get a DBConnection.
- Specified by:
getConnection
in interface DataSource
- Returns:
- a new JDBC connection wrapped inside DBConnection.
releaseConnection
public void releaseConnection(DBConnection conn)
- Method to release an previously opened DBConnection.
- Specified by:
releaseConnection
in interface DataSource
- Parameters:
conn
- DBConnection to be released.
toString
public java.lang.String toString()
- Returns string representation of BasicDataSource.
- Overrides:
toString
in class java.lang.Object