The second is the onfactory class of the connection pool, which maps a connection pool object to a name. The user can obtain the specified connection pool object through this name. The specific code is as follows:
/**
* Connection pool factory, which is often used to store the hash of multiple data source names in combination with the database connection pool
* @ Author liusoft
*/
Public class ConnectionFactory
{
// This hash table is used to save the relationship table of the data source name and connection pool object.
Static Hashtable connectionPools = null;
Static {
ConnectionPools = new Hashtable (2, 0.75F );
}
/**
* Obtain the connection pool object with the specified name from the connection pool factory.
* @ Param dataSource name of the Connection Pool object
* @ Return DataSource return the connection pool object corresponding to the name
* @ Throws NameNotFoundException the specified connection pool cannot be found.
*/
Public static DataSource lookup (String dataSource)
Throws NameNotFoundException
{
Object ds = null;
Ds = connectionPools. get (dataSource );
If (ds = null |! (Ds instanceof DataSource ))
Throw new NameNotFoundException (dataSource );
Return (DataSource) ds;
}
/**
* Bind the specified name with the database connection configuration and initialize the database connection pool.
* @ Param name: name of the Connection Pool