How to configure JDBC connection pool
This article mainly explains "how to configure JDBC connection pool". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to configure JDBC connection pool.
# Database connection pooling
When the system is initialized, the container is created, and some connection objects are applied for in the container. When the user accesses the database, the connection object is obtained from the container. After the user accesses it, the connection object is returned to the container.
# DataSource
GetConnection () * get the connection:
Connection.close (). If the connection object Connection is obtained from the connection pool, the Connection.close () method is called and the connection is no longer closed. It's about returning the connection.
Mysql mysql-connector-java 5.1.28 c3p0 c3p0 0.9.1.2
Define a profile
File name c3p0.properties or c3p0-config.xml
Com.mysql.jdbc.Driver jdbc:mysql://127.0.0.1:3306/demo root baxiang 5 20 3000 com.mysql.jdbc.Driver jdbc:mysql://127.0.0.1:3306/demo root baxiang 5 30 5000
Create the core object, the database connection pool object CombopoolDataSource
Get connection getConnect
# druid
The configuration file ends with a properties file and can be named and placed in any directory.
Druid.properties
Get the database connection pool object through the factory.
Thank you for reading, the above is the content of "how to configure JDBC connection pool". After the study of this article, I believe you have a deeper understanding of how to configure JDBC connection pool, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!