Why use a database connection pool, what good is

1. The basic principle: a pool inside the object, maintaining a certain number of database connections, and external exposure to obtain and return the database connection method.

The external users can access the database via getConnection method, use is completed before the connection is returned through releaseConnection method, attention is connected at this time is not closed, but recovered by the connection pool manager, and ready for the next use.

2. Role

   ① resource reuse (connection multiplexing)

      Since the database connection to be reused to avoid the frequent create and release a lot of performance overhead due to connection. On the basis of the system to reduce consumption, the promotion of a stable system environment (reducing the number of temporary memory fragmentation process-level database, thread)

   ② faster system response time

      Database connection pool during initialization, the number of databases are often created a connection in the standby pool. At this time, the connection pool initialization operation have been completed. For processing the service request, using the currently available direct connection, to avoid the overhead of database connection initialization time and release process, thereby reducing the overall system response time.

   ③ new resource allocation means

      For the system for multiple applications share the same database, in the application layer may be disposed by a database connection, a database connection technology implemented.

   ④ unified connection management, database connections to avoid leaks

     In a more complete database connection pool implementations, according to a predetermined connection timeout occupied MCE connection is occupied, thereby avoiding the conventional database resource leaks that may occur in connection operation

Guess you like

Origin www.cnblogs.com/FengZeng666/p/11610806.html