hibernate 配置 proxool连接池 示例

hibernate 配置proxool连接池 示例

在Hibernate.hbm.xml文件中加入以下代码:

<hibernate-configuration>

<session-factory>
  <property name="hibernate.show_sql">true</property>
  <property name="hibernate.connection.provider_class">//以下配置加载Proxool连接池的类文件,不同的连接池可能用的加载类不一样
   org.hibernate.connection.ProxoolConnectionProvider
  </property>
  <property name="hibernate.proxool.pool_alias">DBPool</property>//这里是给的别名
  <property name="hibernate.proxool.xml">pool.xml</property>//这里是用到的Proxool文件

</session-factory>

</hibernate-configuration>

编写Proxool的配置文件:proxool.xml




<?xml version="1.0" encoding="UTF-8"?>

<something-else-entirely>

<proxool>
  <alias>DBPool</alias>
  <driver-url>
   jdbc:mysql://localhost:3306/shopping
//数据库地址
  </driver-url>

  <driver-class>com.mysql.jdbc.Driver</driver-class>//驱动程序

  <driver-properties>

   <property name="user" value="用户名" />

   <property name="password" value="密码" />

  </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>10</minimum-connection-count>
</proxool>

</something-else-entirely>

你可能感兴趣的:(sql,Hibernate,session,jdbc,configuration)