C3P0,DBCP and Proxool

Source: Internet
Author: User

About C3P0, DBCP and Proxool, such as the comparison, configuration on the internet has a lot of articles, I do not waste everyone's time, mainly on the following I have used these three after the experience.

    1. DBCP: The framework used to be dbcp, Online said, there are many bugs, at least, these bugs, I have not encountered, from the situation of our system operation, can also, there is not too much problem, perhaps our system traffic is not too large (now the daily platform 30 concurrency around). But there is a very pit dad scene, we test the environment, large and small there are 8 projects in the run, the database is with an FTP server set up (limited resources, no way to do), the FTP service will often restart, a restart, DBCP will not be able to automatically connect, the 8 projects to restart a bit. Surely someone would ask, put that database on a machine that doesn't restart very often, is that OK? Yes, this is a way, but still can't avoid the problem that dbcp can't automatically re-connect.
    2. C3P0: The framework is currently using C3P0, this is on the Internet, there are very relevant articles, at the same time, is also recommended by hibernate, here do not waste everyone's time. This connection pool solves the problem that DBCP cannot automatically reconnect, and in terms of stability, very few of our systems are good.
    3. Proxool: About this connection pool, online said example also has a lot, said is the best performance of a connection pool, the pit father is, on-line it and spring integration, there are many are not right, directly through the spring configuration can be, there is no need like online said, put listener, To the servlet, directly through the spring bean configuration, this is also a lot of nets. With regard to this connection pool, when I was testing, I found that by default, it was not automatically reconnected and needed to be configured as follows:

<bean id= "DataSource"class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" > <property name= "driverclassname" value= " Org.logicalcobwebs.proxool.ProxoolDriver "/> <property name=" url "value=" Xxxx.xml "/> </bean> in Xxxx.xm L-in configuration
<proxool> <alias>pool</alias> <driver-url>jdbc:mysql://192.168.1.4:3306/migrate_test?characterencoding=utf-8&autoreconnect=true</driver-url><driver-class>com.mysql.jdbc.driver</driver-class> <driver-properties> <property name= "user" value= "website"/> <property name= "password "value=" website "/> <property name=" AutoReConnect "value=" true "/> </driver-properties> <m Inimum-connection-count>1</minimum-connection-count> <maximum-connection-count>8</ Maximum-connection-count> <prototype-count>1</prototype-count> <test-before-use>true</test-before-use>
The MySQL URL should be followed by autoreconnect=.true, it is worth noting that when using Ibatis, the log will be reported warn:registered a statement as closed which wasn ' t known to be open. That's because in Ibatis PackageOrg.springframework.orm.ibatis; Public classSqlmapclienttemplateextendsJdbcAccessorImplementssqlmapclientoperations { Public<T> T Execute (sqlmapclientcallback<t> action)throwsDataAccessException {... ..finally { //Only close Sqlmapsession if we know we ' ve actually opened it//At the present level. if(Ibatiscon = =NULL) {session.close ();//caused by this paragraph, the session will never close when the pool Ibatiscon is not empty } } } }

if (Ibatiscon! = null), it's okay.

4. According to the above three connection pools, DBCP takes about 600 milliseconds on first access, C3P0 takes 450 milliseconds, Proxool takes 1356 milliseconds, and after access, the speed is basically within dozens of milliseconds, unless SQL is written in a complex way.

C3P0,DBCP and Proxool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.