Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

2.0 connection pooling and other methodologies

 
anand raman
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys
I wish to understand the difference between connection pooling as specified in JDBC 2.0 optional package and other implementations.
I wish to know why would any JDBC developer wish to implement ConnectionPoolDataSource and PooledConnection when connection pooling can be easily implemented using other methodologies (like store in a ArrayList) e.g DbConnectionBroker from javaexchange.com
What distinct advantages does the JDBC 2.0 acheive.
Thanks
Anand
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by anand raman:
I wish to know why would any JDBC developer wish to implement ConnectionPoolDataSource and PooledConnection when connection pooling can be easily implemented using other methodologies (like store in a ArrayList) e.g DbConnectionBroker from javaexchange.com

First off, you as a JDBC developer will not implement these interfaces any more than you implement Connection or Statement. They are supplied by the JDBC 2.0 driver and you just use them.
One of the most important advantages over any other solution is that they are part of the JDBC API and thereby standardised. Instead of being stuck with a single connection pool implementation, you can choose any driver which implements these interfaces. When you use an application server, you no longer have to supply your own connection pool in order to achieve portability, but can just use the server-provided one.
Another advantage is that, since the pool is part of the JDBC driver, it may be faster and/or more reliable. A good connection pool will ensure that the connections it hands out are fully functional (which is why a vanilla ArrayList is not a good idea). A driver has low-level access to the database and may have ways to test connections that simply aren't available to a JDBC connection pool.
Personally, I also like the fact that you don't have to remember any special syntax to return connections to the pool.
- Peter

[This message has been edited by Peter den Haan (edited June 08, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic