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 Hibernate connects to the configuration

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Editor to share with you how to connect the configuration of Hibernate, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!

In Hibernate3.0, dbcp is no longer supported. The author of Hibernate clearly points out in Hibernate.org that dbcp has BUG in practice, and in some situations there are a lot of empty connections that cannot be released, so the support for dbcp is abandoned. As for c3p0, there are comments that its algorithm is not * *, c3p0 takes up a lot of resources, and its efficiency is not high. Proxool is recommended by many experts, and for the time being, it has the least negative comments.

Taking connection MySQl as an example, this paper introduces three methods of Hibernate connection configuration.

Org.gjt.mm.mysql.Driver jdbc:mysql://localhost:3306/struts?useUnicode=true&characterEncoding=GBK root 8888

The above configuration, in both c3p0 and dbcp, is required because Hibernate generates connections based on the above configuration and gives it to c3p0 or dbcp to manage. However, proxool cannot.

1.C3P0

Just add it to the Hibernate.cfg.xml

5 30 1800 50

And add c3p0-0.8.4.5.jar to classespath

2.dbcp

Add to Hibernate.cfg.xml

100 1 60000 10 100 1 60000 10

And add commons-pool-1.2.jar and commons-dbcp-1.2.1.jar to classespath.

3.proxool

Add to Hibernate.cfg.xml

Pool1

ProxoolConf.xml

Net.sf.

Hibernate.connection.ProxoolConnectionProvider

Then, in the same directory as Hibernate.cfg.xml, add a ProxoolConf.xml file with the following contents

Pool1

Jdbc:mysql:

/ / localhost:3306/struts?useUnicode=true&characterEncoding=GBK

Org.gjt.mm.mysql.Driver

90000

twenty

five

one hundred

ten

And add proxool-0.8.3.jar to classespath

If you are using Hibernate3.1, when you import the Hibernate3.1 package in myeclipse and the advanced support class library at the same time, there are already several connection pools available, such as c3p0heroproxool, etc. As long as you configure it slightly, configure the log (log4j.properties), you can see the running process of the connection pool in detail.

The above is all the contents of the article "how to connect and configure Hibernate". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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

Development

Wechat

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

12
Report