Randy Speh wrote:
> 
> Could you please give me hint on how the new jdbc2pool
> connection pool is supposed to be used?
> 
> I would like to use a OracleConnectionPoolDataSource
> to pool some connections and in another case I'd like
> to use a DataSource object managed by WebSphere.

The pool will use any ConnectionPoolDataSource (CPDS) as its backend
supply of physical database connections.  The backend datasource is
specified using the setDataSourceName method which is used to find the
CPDS using jndi.  The maximum number of connections can be configured on
a per user basis; the rest of the properties are set globally.

The Jdbc2PoolDataSource can be instantiated and initialized using
standard bean introspection methods.  So it should be deployable using
any tool meant for use with DataSources or general javabeans.  It does
use Properties for the per user maximum connections as well as the jndi
environment properties, which are both optional.  I do not know how well
these might be supported by the standard tools.  All the other
properties are String's or int's.  In torque the DataSource(s) can be
bound to jndi using a simple properties file to determine
initialization.

The internal pools are stored in a class attribute Map, so several
instances of the DataSource will share the same connections.  This
arrangement is given as an example in the specification.  A better cache
than a HashMap could be used to add more functionality, but such
optimizations are being left until the future of this pool code is
better determined.

Finally the pool can be initialized and used as a normal class, here is
an example using the DriverAdapterCPDS that comes with the pool:

DriverAdapterCPDS pcds = new DriverAdapterCPDS();
pcds.setDriver("org.gjt.mm.mysql.Driver");
pcds.setUrl("jdbc:mysql://localhost/test");
pcds.setUser("root");
pcds.setPassword("xxx");

Jdbc2PoolDataSource tds = new Jdbc2PoolDataSource();
tds.setConnectionPoolDataSource(pcds);
tds.setDefaultMaxConnections(10);
tds.setMaxExpiryTime(3600);
tds.setConnectionWaitTimeout(10);
tds.setLogInterval(300);

DataSource ds = tds;
...

Connection con = ds.getConnection();


john mcnally

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to