In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how to understand the connection pool in Java Hibernate. The content is concise and easy to understand. It will definitely make you shine. I hope you can gain something from the detailed introduction of this article.
Hibernate supports third-party connection pools, and the officially recommended connection pools are C3P0,Proxool, and DBCP. There are three things to note when configuring connection pools:
Apche's DBCP is supported in Hibernate2, but it is no longer recommended in Hibernate3, and the official explanation is that this connection pool is flawed. If you need DBCP in Hibernate3 for some reason, JNDI is recommended.
By default (i.e., when no connection pool is configured), Hibernate uses the built-in connection pool. However, this connection pool performance is not good, and there are many BUGs (I have been troubled by the eight-hour connection suspension problem in Mysql environment), so the official is only recommended to use in the development environment.
Hibernate2 and Hibernate3 namespaces have changed. For example, when configuring C3P0, the provider_class is net.sf.hibernate.connection.C3P0ConnectionProvider in Hibernate2 environment and org.hibernate.connection.C3P0ConnectionProvider in Hibernate3 environment.
Here are some common connection pool configurations for Hibernate environments:
Hibernate default connection pool
com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/schoolproject true UTF-8 root true org.hibernate.dialect.MySQLDialect
2. C3P0 Connection Configuration
com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/schoolproject true UTF-8 root com.mysql.jdbc.Driver 90000 20 5 100 10
(2)Configure hibernate.cfg.xml file
org.hibernate.connection.ProxoolConnectionProvider DBPool proxoolconf.xml true org.hibernate.dialect.MySQLDialect
hibernate.connection.provider_class defines Hibernate's connection loading class, where Proxool connection pool is used, different connection pools have different loading classes, you can consult Hibernate documentation for relevant information
hibernate.proxool.pool_alias Here is the alias for the connection pool we mentioned above
hibernate.proxool.xml is the location of the configuration file that declares the connection pool to Hibernate. You can use relative or absolute paths. When using relative paths, be sure to be within the Path range! Otherwise, an exception will be thrown.
dialect is a dialect that declares SQL statements
show_sql defines whether to display the SQL language generated by Hibernate, which is generally set to true during debugging and then changed to false after completion, which is conducive to debugging.
Resource file mapping
So that's what connection pools are in Java Hibernate. Have you learned anything? If you want to learn more skills or enrich your knowledge reserves, please pay attention to 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.