principle:
In practical application development, especially in a web application, if JSP, servlet, or EJB uses JDBC to directly access data in the database, each data access request must experience a database connection, open database, access data, and shut down database Connection and other steps, while connecting and opening the database is a work that consumes both resources and time, if this database operation occurs frequently, the performance of the system will inevitably drop, or even cause the system to crash. Database connection pool technology is the most common way to solve this problem, in many application servers (such as WebLogic, WebSphere, JBoss), basically provide this technology, no need to program, but in-depth understanding of this technology is very necessary.
Database connection pool technology is very simple, stored database connections as objects in a Vector object, once database connection is created, different database access requests can share these connections, so that by multiplexing these already established database connections, It can overcome the above disadvantages, which greatly saves system resources and time.
The main operation of the database connection pool is as follows:
(1) Establish a database connection pool object
(2) Create an initial number of database library connections according to the parameters specified in advance
(3) For a database access request, a connection is obtained directly from the connection pool. If there is no idle connection in the database connection pool object, and the number of connections does not reach the maximum, create a new database connection.
(4) Access the database.
(5) Turn off the database and release all database connections.