The latest hibernate (hibernate-release-5.0.2.final) configuration Proxool Connection pool detailed steps

Source: Internet
Author: User

Because the lib/required/of the new hibernatet is very different from the old version, there is a slight difference in configuring the Proxool database connection pool. Here, I write down the detailed steps of the configuration for other children's shoes reference


One add the required jar package to Web-inf/lib


are: All jar packages under Hibernate-release-5.0.2.final/lib/required, Proxool two jar packages: Proxool-0.9.1.jar and Proxool-cglib.jar, followed by Hibernate-proxool-5.0.2.final.jar (PS: Path: hibernate-release-5.0.2.final/lib/optional/proxool/), Finally put Commons-logging-1.1.3.jar and Mysql-connector-java-5.1.26-bin.jar also put in, the final effect is as follows:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/75/F4/wKioL1ZFuvfD7_lkAAAqmLBxcLo174.png "title=" Web-inf/lib "alt=" Wkiol1zfuvfd7_lkaaaqmlbxclo174.png "/>

Note: I will put a few key jar packages in the end of the attachment, do not want to download from the official website can also be downloaded here


The two are configured under SRC Hibernate.cfg.xml and proxool.xml:


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/F4/wKioL1ZFvBOz9pTOAAArnnR7crA903.png "title=" Cheetah 20151113183014.png "alt=" Wkiol1zfvboz9ptoaaarnnr7cra903.png "/>

Below, I post the details of my two files for reference:

Hibernate.cfg.xml:

<?xml version= "1.0"  encoding= "UTF-8"? ><! doctype hibernate-configuration public           "- hibernate/hibernate configuration dtd 3.0//en "            "Http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" >< Hibernate-configuration><session-factory><property name= "Hibernate.proxool.pool_alias" > Proxoolpool</property><property name= "Hibernate.proxool.xml" >proxool.xml</property>< Property name= "Hibernate.connection.provider_class" > Org.hibernate.proxool.internal.proxoolconnectionprovider</property><property name= " Hibernate.proxool.existing_pool ">true</property>                 <!-- SQL dialect --><property  Name= "dialect" >org.hibernate.dialect.mysqldialect</property><property name= "Show_sql" >true</property><mapping resource= "com/ Hibtest1/entity/users.hbm.xml " /></session-factory>

Note:

<property name= "Hibernate.connection.provider_class" > Org.hibernate.proxool.internal.ProxoolConnectionProvider</property> The path here is not the same as before, it has changed.


Proxool.xml:

<?xml version= "1.0"  encoding= "UTF-8"? ><something-else-entirely>  <proxool >    <alias>ProxoolPool</alias>    <driver-url> jdbc:mysql://127.0.0.1:3306/bookshop?useunicode=true&amp;characterencoding=utf-8</driver-url>     <driver-class>com.mysql.jdbc.Driver</driver-class>    < Driver-properties>      <property name= "User"  value= "root"/>       <property name= "Password"  value= "root"/>     </driver-properties>        <!--Maximum number of connections (default 5), which exceeds the number of connections, When there is a request, wait in the queue, the maximum number of waiting requests is determined by Maximum-new-connections  -->     < maximum-connection-count>100</maximum-connection-count>    <!--Minimum number of connections (default 2)-- >   <minimum-connection-count>10</minimum-connection-count> <!--Proxool automatically detects the time interval (in milliseconds) of each connection state, and detects that an idle connection is immediately recycled, Timeout to destroy default 30 seconds-->  

The configuration here is similar to the previous one, and there are detailed comments, so not much to say


Three modify Web-inf/web.xml, add node:


  <servlet>    <servlet-name>proxoolservletconfigurator</ servlet-name><servlet-class>org.logicalcobwebs.proxool.configuration.servletconfigurator</ Servlet-class>    <init-param>      <param-name >xmlfile</param-name>      <param-value>web-inf/classes/ proxool.xml</param-value><!--here corresponds to the XML configuration name you just created-->    </init-param>     <load-on-startup>1</load-on-startup>  </servlet>  < !-- proxool provides a management monitoring tool to view the current database connection situation-->  <servlet>    < Servlet-name>admin</servlet-name>    <servlet-class> org.logicalcobwebs.proxool.admin.servlet.adminservlet</servlet-class>  </servlet>   <servlet-mapping>    <servlet-name&gT admin</servlet-name>    <url-pattern>/adminproxool</url-pattern><!-- The adminproxool here can be customized   -->  </servlet-mapping>

Note: There is no protection domain configured here, so anyone who knows the path (/adminproxool) can view the connection pool information, if necessary, to configure it yourself


Four-Test


Here, it's basically configured, and the database operation behind it is like pure hibernate.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/F4/wKioL1ZFv8GCor5nAAB5EzYyXEQ903.png "title=" Cheetah 20151113175512.png "alt=" Wkiol1zfv8gcor5naab5ezyyxeq903.png "/>

If the project starts up normally, and you can open the page as above, it's already configured

This article is from the "Zifangsky" blog, make sure to keep this source http://983836259.blog.51cto.com/7311475/1712596

The latest hibernate (hibernate-release-5.0.2.final) configuration Proxool Connection pool detailed steps

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.