注:本人用的MySQL是5.1版本,proxool0.9.0RC3,部分参数可能因为版本的差异而有所不同。如有疑问,请到论坛寻求帮助:http://www.javawind.net

1、在hibernate.cfg.xml同级目录下建立Proxool的配置文件 ProxoolConf.xml

<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
 <proxool>
  <alias>javawindPool</alias>
  <driver-url>jdbc:mysql://localhost:3306/bbs?autoReconnect=true&amp;useUnicode=true&amp;characterEncoding=UTF-8</driver-url>
  <driver-class>org.gjt.mm.mysql.Driver</driver-class>
  <driver-properties>
   <property name="user" value="username****"/>
   <property name="password" value="password****"/>
  </driver-properties>
  <house-keeping-sleep-time>90000</house-keeping-sleep-time>
  <maximum-new-connections>20</maximum-new-connections>
  <prototype-count>5</prototype-count>
  <maximum-connection-count>100</maximum-connection-count>
  <minimum-connection-count>5</minimum-connection-count>
 </proxool>
</something-else-entirely>

红色是数据库名称,黄色是数据库连接驱动程序,蓝色是数据库用户名,粉红色是数据库登录密码

2、接下来就是在hibernate.cfg.xml中改配置即可,注意同背景颜色字体的名字必须一致!

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>

     <property name="hibernate.proxool.pool_alias">javawindPool</property> 
     <property name="hibernate.proxool.xml">ProxoolConf.xml</property> 
     <property name="hibernate.connection.driver_class">org.hibernate.connection.ProxoolConnectionProvider</property>  
     <property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
     
     <mapping resource="*********.hbm.xml" />

    </session-factory>
</hibernate-configuration>

3、Proxool 配置文件 解释见:http://www.javawind.net/5b016f381ac56399011ac568919e0001.jhtml

4、本配置需要的驱动程序和jar下载,内含proxool-0.9.0RC3.jar,mysql-connector-java-5.1.6-bin.jar,把这2个jar放到web应用的 WEB-INF/lib 目录下即可!

下载附件 19_0228_2214AFC.rar

5、Proxool 官方:http://proxool.sourceforge.net/