09-10-2009 05:08 AM
Connection pooling is a technique used to avoid the overhead making of new database connection every time. An application or server object requires access to a database. This technique of “pooling” connections is based on the fact that most applications only need a thread to have access JDBC connection when they are actively processing a transaction, which usually take only milliseconds to complete. While not processing a transaction, the connection would otherwise sit idle. Instead, connection pooling allows the idle connection to be used by some other thread to-do his useful work.
Connection pooling enables the ODBC driver to re-use existing connections to a given database from a pool of connections, instead of opening a new connection each time the database is accessed. By enabling connection pooling you can improve the overall performance of your application by lowering the time taken to open a connection to a database in the connection pool.
When a thread needs to do work against a MySQL or other database with
JDBC, it requests a connection from the pool. When the thread is finished using the connection, it returns it to the pool, so that it can be used by any other threads. The overhead time for establishing a database connection is typically around 1 to 3 seconds. This is the time it takes to locate the database server to establish communication channel and exchange information. Sun has standardized the concept of connection pooling in JDBC through the JDBC-2.0 “Optional” interfaces, and all major application servers have implementations of these APIs that work fine with MySQL Connector.