Originally posted by Srividya Shiv:
How do u achieve connection pooling thru Java. Its there in JDBC2.0, But I am not sure how to go about that.
I.K.VISHWANATH
The struts 1.1 connection pool is no more than a wrapper around the Commons DataBase Connection Pool.Originally posted by Axel Janssen:
With struts there is a connection pool, but if I use this, its strongly coupled with struts and its database layer, not presentation layer.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Unless it's done as a learning exercise, I would really discourage you from doing this. There are plenty of good connection pools around (including your favourite application server and the Apache Jakarta DBCP mentioned above) and the world doesn't need another one. Also, a solid connection pool is not trivial to develop. Doing your own thing is reinventing a wheel that's likely to be inferior.Originally posted by Nelson David:
I have develped my ConnetionPooling module
Forget about Vector! It's obsolete, superfluous, has a bloated API, and its synchronization usually buys you nothing but trouble. Use a List implementation from the Collections framework. The equivalent of Vector would be an ArrayList, but for a connection pool a LinkedList would actually be more appropriate. I will leave the reasons why as an exercise for the reader[...] I am caching connections in Vector object
Ensure each connection gets a fair amount of use (i.e. use a FIFO list rather than a LIFO list). Use a test query to test each connection before giving it to the client code, and/or actively expire connections after a certain time if inactivity, and/or use a reaper thread to periodically test connections. Those are the naive approaches. Much better would be to use the connection pool support that is probably offered by the database driver -- i.e. PooledDataSource and friends. This has an event model which can notify your pool when a connection is knocked out due to some fatal error.the database server later on closes the connection when ther is no activity on connection, leaving my Vector object holding closed connections, how do i prevent it?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Srividya Shiv:
How do u achieve connection pooling thru Java. Its there in JDBC2.0, But I am not sure how to go about that.
Jon
Bruno Arantes Bueno.<br />Certified Lotus Specialist, SCJP 1.4.
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
|