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

Several ways of creating connection Pool by spring

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

There are many ways for spring to use connection pooling, such as jdbc (not using connection pooling) and c3p0.dbcpjndi. These are described in the following code:

1.jdbc mode

Using DriverManagerDataSource,DriverManagerDataSource to establish a connection is to create a new connection as long as there is a connection, which has no function of connection pool at all.

${jdbc.driverClassName} ${jdbc.url} ${jdbc.username} ${jdbc.password}

2.C3P0 connection pool

Using ComboPooledDataSource

3.DBCP connection pool

Using BasicDataSource

Because spring has good support for C3P0DBCP connection pool, only the above configuration is needed to configure the connection pool for the corresponding data source.

4.JNDI mode

Using JndiObjectFactoryBean

Java:comp/env/jdbc/roseindiaDB_local

This way of using JDNI also needs the support of the server, such as adding the corresponding code to the context.xml of tomcat. For more information, please see the introduction of the previous article.

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

Database

Wechat

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

12
Report