• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ConnectionPoolDataSource

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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>
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One Correction:
ConnectionPoolDataSource is a Interface.
So You cann't use ConnectionPoolDataSource ds= new ConnectionPoolDataSource();

Regards,
Raman
 
There is no "i" in denial. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic