wood burning stoves 2.0*
The moose likes JDBC and the fly likes ConnectionPoolDataSource Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "ConnectionPoolDataSource" Watch "ConnectionPoolDataSource" New topic
Author

ConnectionPoolDataSource

karim qazi
Greenhorn

Joined: Mar 22, 2001
Posts: 20
Can anyone explain to me how to use the ConnectionPoolDataSource vs. DataSource.
I know how to get a connection using the DataSource interface how can you get a ConnectionPoolDataSource instead?
Robert Brunner
Ranch Hand

Joined: Jul 18, 2001
Posts: 49
Originally posted by karim qazi:
Can anyone explain to me how to use the ConnectionPoolDataSource vs. DataSource.
I know how to get a connection using the DataSource interface how can you get a ConnectionPoolDataSource instead?


Easy, rather than creating an object that implements the DataSource interface, you implement an object that implements the ConnectionPoolDataSource.
You then get a PooledConnection object via getPooledConnection(), and then you get a connection from this PooledConnection via getConnection(). Everything else is the same. So essentially, you only have one changed step, and one additional step to take advantage of connection pooling.
<pre>
ConnectionPoolDataSource ds = new ConnectionPoolDataSource() ;
// Set datasource properties
PooledConnection pcon = ds.getPooledConnection() ;
Connection con = pcon.getConnection() ;
<pre>
Malli Raman
Ranch Hand

Joined: Nov 07, 2001
Posts: 312
One Correction:
ConnectionPoolDataSource is a Interface.
So You cann't use ConnectionPoolDataSource ds= new ConnectionPoolDataSource();

Regards,
Raman
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ConnectionPoolDataSource
 
Similar Threads
Difference between DataSource and ConnectionPoolDataSource
DataSource and JNDI
Create ConnectionPoolDataSource and PooledConnection in Weblogic 6.1
problem in getting PooledConnection
How do close/destroy connection pool?