Overview
The database connection pool was learned at. NET and has been exposed in SQL Server, but when used, it's very important because, VS and SQL Server and the operating system are Microsoft's, others have made a good integration, when we use the database connection pool, Just need to modify the corresponding connection string, but, in Java is not the same, because Java is open source, he only provides a standard, the rest, no matter which company can be implemented, well, to the next, we continue to say our database connection pool.
no connection pooling and connection poolingNo database connection pool
There is a database connection pool
implementation of database connection pooling
Java is open source, son company itself does not implement the database connection pool, but there are many third-party implementations of the framework, such as: Tomcat, DBCP and C3P0, of course, we can also implement the database connection pool, due to their own implementation of the database connection pool specific code is not provided here, So, here's a description of the process of implementing your database connection pool.
Define a factory class that defines a dynamic proxy that declares a collection within the factory class, creates a specified number of database connection objects when the factory class initializes, and puts them into the collection, the dynamic method inside the proxy class determines whether the connection object is a closed method, and if so, puts the proxy object into the collection in the Factory class ( When removed, subtracts the object from the collection).
Their own implementation of the database connection pool of the general idea is this, interested students can realize, the following provides a demo of Tomcat, DBCP and C3P0.
Summarydatabase connection pooling is one aspect of system optimization, and there are many other aspects, such as caching, server optimization.
JDBC Database connection Pool