Use of Proxool + MySQL + servelt

Source: Internet
Author: User

Proxool Introduction

The Proxool connection pool is an open source project under SourceForge that provides a robust and easy-to-use connection pool, the most critical of which is the ability to monitor the connection pool, which is easy to use and facilitates the discovery of connection leaks. Open Source project address is: http://proxool.sourceforge.net/

Proxool provides a number of configuration properties with the following attributes, and of course it is recommended to view the official document Http://proxool.sourceforge.net/properties.html directly:

1. Configure Proxool.xml

<?xml version= "1.0" encoding= "Utf-8"?>
<something-else-entirely>
<proxool>

<alias>dbname</alias> < aliases!--data sources--

<!--database connection information --
<driver-url>jdbc:mysql://localhost:3306/zz</driver-url>

<driver-class>com.mysql.jdbc.driver </driver-class>

<driver-properties>
<property name= "user" value= "root"/>
<property name= "password" value= "123123"/>
<property name= "Useunicode" value= "true"/> <!--using Unicode character encoding set --
<property name= "characterencoding" value= "Utf-8"/> <!--character coded to Utf-8
</driver-properties>
    <!--maximum number of connections--


< minimum number of connections!----
<minimum-connection-count>10</minimum-connection-count>

    <!--minimum Increment--
<simultaneous-build-throttle>10</simultaneous-build-throttle>




<prototype-count>5</prototype-count>
    <!--detect before use
<test-before-use>true</test-before-use>
    <!--This is the syntax for MySQL, different databases--
<!--This is how Oracle is written, Each database has a difference --
  </proxool>

</something-else-entirely>

2. Configure Web. XML

<servlet><servlet-name>ServletConfigurator</servlet-name><servlet-class>   Org.logicalcobwebs.proxool.configuration.servletconfigurator</servlet-class><init-param>   < param-name>xmlfile</param-name>   <param-value>WEB-INF/proxool.xml</param-value>  <!--proxool.xml configuration file Location--</init-param>   <load-on-startup>1</load-on-startup > </servlet>

3. Get the connection

1 Importjava.sql.Connection;2 ImportJava.sql.DriverManager;3 Importjava.sql.PreparedStatement;4 ImportJava.sql.ResultSet;5 Importjava.sql.SQLException;6 7 /**8  * @authorCTD9  *Ten  */ One  Public classDbutils { A    -     Private StaticDbutils me=Newdbutils (); -      the     Privatedbutils () {} -      -      Public Staticdbutils getinstance () -     { +         returnme; -     } +      A     /** at * Get database connection -      * @return -      */ -      PublicConnection getconn () -     { -          inConnection conn=NULL; -          to         Try { +             //See if this driver entry class exists in the Classpath -Class.forName ("Org.logicalcobwebs.proxool.ProxoolDriver"); theConn=drivermanager.getconnection ("Proxool.dbname"); //proxool. Database aliases  *              $}Catch(ClassNotFoundException e) {Panax Notoginseng             //TODO auto-generated Catch block - e.printstacktrace (); the}Catch(SQLException e) { +             //TODO auto-generated Catch block A e.printstacktrace (); the         }  +          -         returnConn; $          $     } -      -     /** the * Release Database Resources -      * @paramConnWuyi      * @parampstmt the      * @paramRSet -      */ Wu      Public voidreleaseres (Connection conn,preparedstatement pstmt,resultset rset) -     { About         Try{ $           if(rset!=NULL) Rset.close (); -           if(pstmt!=NULL) Pstmt.close (); -           if(conn!=NULL) Conn.close (); -}Catch(SQLException e) A         { + e.printstacktrace (); the         } -     } the}

Use of Proxool + MySQL + servelt

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.