DEVFYI - Developer Resource - FYI

How can I pool my database connections so I don't have to keep reconnecting to the database?

JDBC Interview Questions and Answers


(Continued from previous question...)

How can I pool my database connections so I don't have to keep reconnecting to the database?

There are plenty of connection pool implementations described in books or availalble on the net. Most of them implement the same model. The process is always the same :

* you gets a reference to the pool
* you gets a free connection from the pool
* you performs your different tasks
* you frees the connection to the pool

Since your application retrieves a pooled connection, you don't consume your time to connect / disconnect from your data source. You can find some implementation of pooled connection over the net, for example:
* Db Connection Broker (http://www.javaexchange.com/), a package quite stable ( I used it in the past to pool an ORACLE database on VMS system)
You can look at the JDBC 2.0 standard extension API specification from SUN which defines a number of additional concepts.

(Continued on next question...)

Other Interview Questions