All three connections are connected to MySQl as an example.
Org. gjt. mm. mysql. Driver
Jdbc: mysql: // localhost: 3306/struts? UseUnicode = true & characterEncoding = GBK
Root
8888
The above configuration is required in c3p0 and dbcp, because hibernate will generate connections based on the above configuration and then hand it over to c3p0 or dbcp for management. however, proxool is not supported. Although it is convinced that proxool can also be used with hibernate, I also fail to configure it according to the instructions in the official document, no one answered questions from sun or hibernat's official website for a few days. Later, I can only let proxool itself generate a connection, which will be discussed below.
1. C3P0
You only need to add
5
30
1800
50
Also add c3p0-0.8.4.5.jar in classespath
2. dbcp
Add in hibernate. cfg. xml
100
1
60000
10
100
1
60000
10
Commons-pool-1.2.jar and commons-dbcp-1.2.1.jar are also added to classespath.
3. proxool
Add in hibernate. cfg. xml
Pool1
ProxoolConf. xml
Net. sf. hibernate. connection. ProxoolConnectionProvider
Then, add
ProxoolConf. xmlFile, the content is
Pool1
Jdbc: mysql: // localhost: 3306/struts? UseUnicode = true & characterEncoding = GBK
Org. gjt. mm. mysql. Driver
90000
20
5
100
10
And add proxool-0.8.3.jar to classespath
Conclusion:
In hibernate3.0, dbcp is no longer supported. In hibernate.org, the author of hibernate explicitly pointed out that dbcp has bugs in practice and many blank Connections cannot be released in some cases, therefore, dbcp support is abandoned. I don't know if this problem has been solved in the latest version of dbcp. I used dbcp in a project with a low traffic volume and it has not encountered any problems after running for more than a year. However, many netizens have pointed out that dbcp may be unstable in large applications. Therefore, I think dbcp should be cautious when the truth is unconfirmed.
As for c3p0, some people commented that its algorithm is not optimal. Moreover, in matrix, I saw some netizens doing an experiment and used several commonly used connection pools in the same project, then test its performance. It is found that c3p0 occupies a large amount of resources and the efficiency is not high.
Therefore, for the above reasons, it takes me two nights to study the proxool configuration. Many proxool experts recommend it, and for the moment, it is the least negative comments. Proxool is also used for projects in Samsung.
You are welcome to study the connection pool issues and share your experiences.