在Hibernate里配置Proxool连接池

1. 需要jar文件

proxool-cglib.jar

proxool-0.9.1.jar

下载地址:http://proxool.sourceforge.net

proxool-0.9.1 中包含这两个jar文件,其中proxool-0.9.1.jar地址需要放在环境变量classpath中.

2.修改hibernate.cfg.xml文件.

 

在文件中增加下面内容:

pool1 
ProxoolConf.xml 
org.hibernate.connection.ProxoolConnectionProvider

 

依次是连接池别名,对应xml文件及驱动,整个文件如下:

 


          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">


 
 
  org.hibernate.dialect.Oracle9Dialect
  OracleServer    
  
  true
  true
  
  
   org.hibernate.hql.classic.ClassicQueryTranslatorFactory
  

  
  0
  
pool1
  ProxoolConf.xml
  org.hibernate.connection.ProxoolConnectionProvider

  
     resource="com/netinfo/struts/domain/domain00/T0000powerinfo.hbm.xml" />
 

 

3.增加ProxoolConf.xml文件,放在hibernate.cfg.xml文件同级目录下.

 

xml version="1.0" encoding="utf-8"?>

<something-else-entirely>
    <proxool>
        <alias>pool1alias>

        <driver-url>jdbc:mysql://localhost:3306/struts?useUnicode=true&characterEncoding=GBKdriver-url>
        <driver-class>org.gjt.mm.mysql.Driverdriver-class>
        <driver-properties>
            <property name="user" value="root"/>
            <property name="password" value="8888"/>
        driver-properties>

        <house-keeping-sleep-time>90000house-keeping-sleep-time>

        <maximum-new-connections>20maximum-new-connections>

        <prototype-count>5prototype-count>

        <maximum-connection-count>100maximum-connection-count>

        <minimum-connection-count>10minimum-connection-count>
    proxool>
something-else-entirely>

 

常见错误:

1、org.hibernate.HibernateException: Proxool Provider unable to load JAXP configurator file: proxool.xml
org.logicalcobwebs.proxool.ProxoolException: Parsing failed.

将proxoolconf.xml里面的中文删除即可。

2、proxool-0.8.3.jar中包含了proxool-0.9.1.jar和proxool-cglib.jar 使用proxool-0.9.1.jar记得加上proxool-cglib.jar

 

你可能感兴趣的:(Hibernate)