Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure JDBC connection pool

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report