Hibernate configure connection pooling in 3 ways

Source: Internet
Author: User
Tags connection pooling

three connections are all connected to MySQL for example.


The above configuration, in C3p0 and DBCP, is required because hibernate generates connections based on the above configuration, Again to C3P0 or DBCP management. However, Proxool can not, although the convincing document said Proxool may also be combined with hibernate, but I follow the official documents on how to match also error, and, to the official website of Sun and Hibernat asked a few days, None of them replied. Later I can only let proxool itself to generate the connection, which is said below.


1, c3p0



2, DBCP



3, Proxool


then, in the same directory as Hibernate.cfg.xml, add a Proxoolconf.xmlfile, content is

<?xml version= "1.0" encoding= "Utf-8"?> <!--the Proxool configuration can be embedded within your own application ' s. Anything outside the ' proxool ' tag is ignored. -<something-else-entirely> <proxool> <alias>pool1</alias> <!-- Proxool can only manage connections generated by yourself-<driver-url>jdbc:mysql://localhost:3306/struts?useUnicode=true& Characterencoding=gbk</driver-url> <driver-class>org.gjt.mm.mysql.Driver</driver-class> < driver-properties> <property name= "user" value= "root"/> <property name= "password" value= "8888"/> </ driver-properties> <!--Proxool automatically detects the time interval (in milliseconds) of each connection state, and detects that an idle connection is immediately recycled, and the timeout is destroyed--and 

and add Proxool-0.8.3.jar to the Classespath.

Conclusion:

because in hibernate3.0, already no longer support DBCP, hibernate author in hibernate.org, clearly pointed out in practice dbcp have a bug, in some cases will generate a lot of empty connection can not be released, So abandoned the support of the DBCP. I don't know if I solved this problem in the latest version of DBCP, I used DBCP in a project with a small amount of traffic, and I haven't had any problems for more than a year. However, on the internet there are many netizens pointed out that dbcp in large-scale applications will appear unstable situation. So in the case of unconfirmed facts, I feel that I have a cautious attitude towards dbcp.

As for C3P0, commented that its algorithm is not optimal, and, in the Matrix, I saw a netizen did an experiment, in the same project used several common connection pool, and then test its performance, found that c3p0 occupies a large resource, efficiency is not high.

therefore, based on the above reasons, I spent two nights to study the configuration of Proxool, proxool Many experts recommend to use, and for the time being, negative evaluation is the least one. There are also projects in Samsung with Proxool.

Welcome to join the pool of the problem of more research, many published their experience.

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.