hibernate中配置proxool

[转]http://cheneyhu.blog.sohu.com/134397796.html

 

搞了一天的在hibernate中配置proxool,终于算是调通过了,其中遇到了许多问题,在这里和大家分享一下.

1.官网下载地址:
http://sourceforge.net/projects/proxool/files/

 

2.说明一下我的配置环境

JRE1.6, tomcat6.0,hibernate3.1, proxool-0.9.0RC3

数据库为MSSQL2005  JDBC驱动为sqljdbc.jar

 

3.配置步聚

(1) 建立proxool.xml文件,路径为根目录src下即与hibernate.cfg.xml同目录,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!--
  the proxool configuration can be embedded within your own application's.
  Anything outside the "proxool" tag is ignored.
-->
<something-else-entirely>
  <proxool>
    <alias>mssqlProxool</alias>
    <driver-url>jdbc:sqlserver://XXX.XXX.XXX.XX:1433;databaseName=XXX</driver-url>
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <driver-properties>
      <property name="user" value="sa" />
      <property name="password" value="XXX" />
    </driver-properties>
    <house-keeping-test-sql>select CURRENT_DATE</house-keeping-test-sql>
    <house-keeping-sleep-time>90000</house-keeping-sleep-time>
    <simultaneous-build-throttle>20</simultaneous-build-throttle>
    <maximum-connection-count>100</maximum-connection-count>
    <minimum-connection-count>10</minimum-connection-count>
    <maximum-connection-lifetime>3600000</maximum-connection-lifetime>
  </proxool>
</something-else-entirely>

 

属性列表说明:

fatal-sql-exception: 它是一个逗号分割的信息片段.当一个SQL异常发生时,他的异常信息将与这个信息片段进行比较.如果在片段中存在,那么这个异常将被认为是个致命错误 (Fatal SQL Exception ).这种情况下,数据库连接将要被放弃.无论发生什么,这个异常将会被重掷以提供给消费者.用户最好自己配置一个不同的异常来抛出.

fatal-sql-exception-wrapper-class:正如上面所说,你最好配置一个不同的异常来重掷.利用这个属性,用户可以包装

SQLException,使他变成另外一个异常.这个异常或者继承SQLException或者继承字RuntimeException.proxool

自带了2个实现:'org.logicalcobwebs.proxool.FatalSQLException' 和'org.logicalcobwebs.proxool.FatalRuntimeException'.后者更合适.

house-keeping-sleep-time: house keeper 保留线程处于睡眠状态的最长时间,house keeper 的职责就是检查

各个连接的状态,并判断是否需要销毁或者创建.

house-keeping-test-sql: 如果发现了空闲的数据库连接.house keeper 将会用这个语句来测试.这个语句最好非

常快的被执行.如果没有定义,测试过程将会被忽略。

injectable-connection-interface: 允许proxool实现被代理的connection对象的方法.

injectable-statement-interface: 允许proxool实现被代理的Statement 对象方法.

injectable-prepared-statement-interface: 允许proxool实现被代理的PreparedStatement 对象方法.

injectable-callable-statement-interface: 允许proxool实现被代理的CallableStatement 对象方法.

jmx: 如果属性为true,就会注册一个消息Bean到jms服务,消息Bean对象名: "Proxool:type=Pool, name=<alias>". 默认值为false.

jmx-agent-id: 一个逗号分隔的JMX代理列表(如使用MBeanServerFactory.findMBeanServer(String agentId)注册的连接池。)这个属性是仅当"jmx"属性设置为"true"才有效。所有注册jmx服务器使用这个属性是不确定的

jndi-name: 数据源的名称

maximum-active-time: 如果housekeeper 检测到某个线程的活动时间大于这个数值.它将会杀掉这个线程.

所以确认一下你的服务器的带宽.然后定一个合适的值.默认是5分钟.

maximum-connection-count: 最大的数据库连接数.

maximum-connection-lifetime: 一个线程的最大寿命.

minimum-connection-count: 最小的数据库连接数

overload-without-refusal-lifetime: 这可以帮助我们确定连接池的状态。如果我们已经拒绝了一个连接在这个设定值

(毫秒),然后被认为是超载。默认为60秒。

prototype-count: 连接池中可用的连接数量.如果当前的连接池中的连接少于这个数值.新的连接将被建立

(假设没有超过最大可用数).例如.我们有3个活动连接2个可用连接,而我们的prototype-count是4,那么数

据库连接池将试图建立另外2个连接.这和 minimum-connection-count不同. minimum-connection-count

把活动的连接也计算在内.prototype-count 是spare connections 的数量.

recently-started-threshold: 这可以帮助我们确定连接池的状态,连接数少还是多或超载。只要至少有一个连接

已开始在此值(毫秒)内,或者有一些多余的可用连接,那么我们假设连接池是开启的。默认为60秒

simultaneous-build-throttle: 这是我们可一次建立的最大连接数。那就是新增的连接请求,但还没有可供使用的连接。由于连接可以使用多线程,在有限的时间之间建立联系从而带来可用连接, 但是我们需要通过一些方式确认一些线程并不是立即响应连接请求的,默认是10。

statistics: 连接池使用状况统计。 参数“10s,1m,1d”

statistics-log-level: 日志统计跟踪类型。 参数“ERROR”或 “INFO”

test-before-use: 如果为true,在每个连接被测试前都会服务这个连接,如果一个连接失败,那么将被丢弃,另一个连接将会被处理,如果所有连接都失败,一个新的连接将会被建立。否则将会抛出一个SQLException异常。

test-after-use: 如果为true,在每个连接被测试后都会服务这个连接,使其回到连接池中,如果连接失败,那么将被废弃。

trace: 如果为true,那么每个被执行的SQL语句将会在执行期被log记录(DEBUG LEVEL).你也可以注册一个ConnectionListener (参看ProxoolFacade)得到这些信息.

 

(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">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.proxool.pool_alias">mssqlProxool</property>
        <property name="hibernate.proxool.xml">proxool.xml</property>
        <property name="hibernate.connection.provider_class">org.hibernate.connection.ProxoolConnectionProvider</property>
        <property name="hibernate.proxool.existing_pool">true</property>  
       
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
        <property name="hibernate.cache.use_query_cache">true</property>
    </session-factory>
</hibernate-configuration>

这里需注意三点:

1.别名与proxool中的别名保持一致.

2.路径确保正确

3一般网上只说明了以上两点,hibernate.proxool.existing_pool 这个参数很重要

hibernate.proxool.existing_pool:此值设为 false,当 hibernate 开始被调用时,就会初始化 proxool,进行数据库连接等操作;

 

(3)要让程序直接使用proxool连接池,可以在web.xml中配置初始化servlet,在web容器加载的时候自动加载配置文件

    <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/classes/proxool.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

注意:如果同时配置了web.xml和hibernate.cfg.xml会产生错误:

org.logicalcobwebs.proxool.ProxoolException:   Parsing   failed.

因为同名的proxool连接池已经启动,而hibernate开始运行时会自己启动关联的proxool连接池.

所以此时应改变hibernate.cfg.xml配置为:

< property   name = "hibernate.proxool.existing_pool" > true </ property >

 

(4)这一步是可选的 在应用中实时监控连接池

    <servlet>
         <servlet-name>adminProxool</servlet-name>
         <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
     </servlet>
     <servlet-mapping>
         <servlet-name>adminProxool</servlet-name>
         <url-pattern>/admin/proxool</url-pattern>
     </servlet-mapping>

     访问http://localhost:8080/项目名称/admin/proxool即可看到页面

 

4.错误解析:

常遇到的问题是

org.hibernate.HibernateException:Proxool Provider unable to load JAXP configurator file:proxool.xml

这有可能是由于proxool包版本的问题,我先后试过proxool-0.9.0RC1 proxool-0.9.0RC2 proxool-0.9.0RC3

proxool-0.9.0 proxool-0.9.1 结果是高版本的0.9.0和0.9.1都会有这个问题,使用RC1或者以下的版本则没有.

 

希望以上的解说写成word文档提供下载,希望能给准备使用proxool的朋友以帮助.

 

 

 

 

另一个配置属性文章

 

 

 

更详细的proxool.xml的配置属性说明:

Xml代码
  1. <? xml version = "1.0" encoding = "ISO-8859-1" ?>   
  2. <!--   
  3. Properties for Proxool Configurator testing. Defines the same parameters as   
  4. TestHelper.buildCompleteAlternativeProperties()   
  5. -- >   
  6. < something-else-entirely xmlns = "http://sumthin.else.entirely" xmlns:proxool = "The latest version is available at http://proxool.sourceforge.net/xml-namespace" >   
  7.      < proxool:proxool >   
  8.          < proxool:alias > xml-test-ns </ proxool:alias >   
  9.          < proxool:driver-url > jdbc:hsqldb:db/test </ proxool:driver-url >   
  10.          < proxool:driver-class > org.hsqldb.jdbcDriver </ proxool:driver-class >   
  11.          < proxool:driver-properties >   
  12.              < proxool:property name = "user" value = "sa" />   
  13.              < proxool:property name = "password" value = "" />   
  14.          </ proxool:driver-properties >   
  15.          < proxool:house-keeping-sleep-time > 40000 </ proxool:house-keeping-sleep-time >   
  16.          < proxool:house-keeping-test-sql > select CURRENT_DATE </ proxool:house-keeping-test-sql >   
  17.          < proxool:maximum-connection-count > 10 </ proxool:maximum-connection-count >   
  18.          < proxool:minimum-connection-count > 3 </ proxool:minimum-connection-count >   
  19.          < proxool:maximum-connection-lifetime > 18000000 </ proxool:maximum-connection-lifetime > <!-- 5 hours -->   
  20.          < proxool:simultaneous-build-throttle > 5 </ proxool:simultaneous-build-throttle >   
  21.          < proxool:recently-started-threshold > 40000 </ proxool:recently-started-threshold >   
  22.          < proxool:overload-without-refusal-lifetime > 50000 </ proxool:overload-without-refusal-lifetime >   
  23.          < proxool:maximum-active-time > 60000 </ proxool:maximum-active-time >   
  24.          < proxool:verbose > true </ proxool:verbose >   
  25.          < proxool:trace > true </ proxool:trace >   
  26.          < proxool:fatal-sql-exception > Fatal error </ proxool:fatal-sql-exception >   
  27.          < proxool:prototype-count > 2 </ proxool:prototype-count >   
  28.      </ proxool:proxool >   
  29.      < nothing-to-do-with-proxool >   
  30.          < proxool:proxool >   
  31.              < proxool:alias > xml-test-ns-2 </ proxool:alias >   
  32.              < proxool:driver-url > jdbc:hsqldb:db/test </ proxool:driver-url >   
  33.              < proxool:driver-class > org.hsqldb.jdbcDriver </ proxool:driver-class >   
  34.              < proxool:driver-properties >   
  35.                  < proxool:property name = "user" value = "sa" />   
  36.                  < proxool:property name = "password" value = "" />   
  37.              </ proxool:driver-properties >   
  38.              < proxool:house-keeping-sleep-time > 40000 </ proxool:house-keeping-sleep-time >   
  39.              < proxool:house-keeping-test-sql > select CURRENT_DATE </ proxool:house-keeping-test-sql >   
  40.              < proxool:maximum-connection-count > 10 </ proxool:maximum-connection-count >   
  41.              < proxool:minimum-connection-count > 3 </ proxool:minimum-connection-count >   
  42.              < proxool:maximum-connection-lifetime > 18000000 </ proxool:maximum-connection-lifetime > <!-- 5 hours -->   
  43.              < proxool:simultaneous-build-throttle > 5 </ proxool:simultaneous-build-throttle >   
  44.              < proxool:recently-started-threshold > 40000 </ proxool:recently-started-threshold >   
  45.              < proxool:overload-without-refusal-lifetime > 50000 </ proxool:overload-without-refusal-lifetime >   
  46.              < proxool:maximum-active-time > 60000 </ proxool:maximum-active-time >   
  47.              < proxool:verbose > true </ proxool:verbose >   
  48.              < proxool:trace > true </ proxool:trace >   
  49.              < proxool:fatal-sql-exception > Fatal error </ proxool:fatal-sql-exception >   
  50.              < proxool:prototype-count > 2 </ proxool:prototype-count >   
  51.          </ proxool:proxool >   
  52.      </ nothing-to-do-with-proxool >   
  53. </ something-else-entirely >   

属性列表说明:

fatal-sql-exception : 它是一个逗号分割的信息片段.当一个SQL异常发生时,他的异常信息将与这个信息片段进行比较.如果在片段中存在,那么这个异常将被认为是个致命错误 (Fatal SQL Exception ).这种情况下,数据库连接将要被放弃.无论发生什么,这个异常将会被重掷以提供给消费者.用户最好自己配置一个不同的异常来抛出.

fatal-sql-exception-wrapper-class : 正 如上面所说,你最好配置一个不同的异常来重掷.利用这个属性,用户可以包装SQLException,使他变成另外一个异常.这个异常或者继承 SQLException或者继承字RuntimeException.proxool自带了2个实 现:'org.logicalcobwebs.proxool.FatalSQLException' 和'org.logicalcobwebs.proxool.FatalRuntimeException' .后者更合适.

house-keeping-sleep-time : house keeper 保留线程处于睡眠状态的最长时间,house keeper 的职责就是检查各个连接的状态,并判断是否需要销毁或者创建.

house-keeping-test-sql : 如果发现了空闲的数据库连接.house keeper 将会用这个语句来测试.这个语句最好非常快的被执行.如果没有定义,测试过程将会被忽略。

injectable-connection-interface : 允许proxool实现被代理的connection对象的方法.

injectable-statement-interface : 允许proxool实现被代理的Statement 对象方法.

injectable-prepared-statement-interface : 允许proxool实现被代理的PreparedStatement 对象方法.

injectable-callable-statement-interface : 允许proxool实现被代理的CallableStatement 对象方法.

jmx :

jmx-agent-id :

jndi-name : 数据源的名称

maximum-active-time : 如果housekeeper 检测到某个线程的活动时间大于这个数值.它将会杀掉这个线程.所以确认一下你的服务器的带宽.然后定一个合适的值.默认是5分钟.

maximum-connection-count : 最大的数据库连接数.

maximum-connection-lifetime : 一个线程的最大寿命.

minimum-connection-count : 最小的数据库连接数

overload-without-refusal-lifetime :

prototype-count : 连接池中可用的连接数量.如果当前的连接池中的连接少于这个数值.新的连接将被建立(假设没有超过最大可用数).例如.我们有3个活动连接2个可用连接, 而我们的prototype-count是4,那么数据库连接池将试图建立另外2个连接.这和 minimum-connection-count不同. minimum-connection-count把活动的连接也计算在内.prototype-count 是spare connections 的数量.

recently-started-threshold :

simultaneous-build-throttle :

statistics : 连接池使用状况统计。 参数“10s,1m,1d”

statistics-log-level : 日志统计跟踪类型。 参数“ERROR”或 “INFO”

test-before-use :

test-after-use :

trace : 如果为true,那么每个被执行的SQL语句将会在执行期被log记录(DEBUG LEVEL).你也可以注册一个ConnectionListener (参看ProxoolFacade)得到这些信息.

verbose : 详细信息设置。 参数 bool 值

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
hibernate.properties # # Hibernate, Relational Persistence for Idiomatic Java # # License: GNU Lesser General Public License (LGPL), version 2.1 or later. # See the lgpl.txt file in the root directory or . # ###################### ### Query Language ### ###################### ## define query language constants / function names hibernate.query.substitutions yes 'Y', no 'N' ## select the classic query parser #hibernate.query.factory_class org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory ################# ### Platforms ### ################# ## JNDI Datasource #hibernate.connection.datasource jdbc/test #hibernate.connection.username db2 #hibernate.connection.password db2 ## HypersonicSQL hibernate.dialect org.hibernate.dialect.HSQLDialect hibernate.connection.driver_class org.hsqldb.jdbcDriver hibernate.connection.username sa hibernate.connection.password hibernate.connection.url jdbc:hsqldb:./build/db/hsqldb/hibernate #hibernate.connection.url jdbc:hsqldb:hsql://localhost #hibernate.connection.url jdbc:hsqldb:test ## H2 (www.h2database.com) #hibernate.dialect org.hibernate.dialect.H2Dialect #hibernate.connection.driver_class org.h2.Driver #hibernate.connection.username sa #hibernate.connection.password #hibernate.connection.url jdbc:h2:mem:./build/db/h2/hibernate #hibernate.connection.url jdbc:h2:testdb/h2test #hibernate.connection.url jdbc:h2:mem:imdb1 #hibernate.connection.url jdbc:h2:tcp://dbserv:8084/sample; #hibernate.connection.url jdbc:h2:ssl://secureserv:8085/sample; #hibernate.connection.url jdbc:h2:ssl://secureserv/testdb;cipher=AES ## MySQL #hibernate.dialect org.hibernate.dialect.MySQLDialect #hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect #hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect #hibernate.connection.driver_class com.mysql.jdbc.Driver #hibernate.connection.url jdbc:mysql:///test #hibernate.connection.username gavin #hibernate.connection.password ## Oracle #hibernate.dialect org.hibernate.dialect.Oracle8iDialect #hibernate.dialect org.hibernate.dialect.Oracle9iDialect #hibernate.dialect org.hibernate.dialect.Oracle10gDialect #hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver #hibernate.connection.username ora #hibernate.connection.password ora #hibernate.connection.url jdbc:oracle:thin:@localhost:1521:orcl #hibernate.connection.url jdbc:oracle:thin:@localhost:1522:XE ## PostgreSQL #hibernate.dialect org.hibernate.dialect.PostgreSQLDialect #hibernate.connection.driver_class org.postgresql.Driver #hibernate.connection.url jdbc:postgresql:template1 #hibernate.connection.username pg #hibernate.connection.password ## DB2 #hibernate.dialect org.hibernate.dialect.DB2Dialect #hibernate.connection.driver_class com.ibm.db2.jcc.DB2Driver #hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver #hibernate.connection.url jdbc:db2://localhost:50000/somename #hibernate.connection.url jdbc:db2:somename #hibernate.connection.username db2 #hibernate.connection.password db2 ## TimesTen #hibernate.dialect org.hibernate.dialect.TimesTenDialect #hibernate.connection.driver_class com.timesten.jdbc.TimesTenDriver #hibernate.connection.url jdbc:timesten:direct:test #hibernate.connection.username #hibernate.connection.password ## DB2/400 #hibernate.dialect org.hibernate.dialect.DB2400Dialect #hibernate.connection.username user #hibernate.connection.password password ## Native driver #hibernate.connection.driver_class COM.ibm.db2.jdbc.app.DB2Driver #hibernate.connection.url jdbc:db2://systemname ## Toolbox driver #hibernate.connection.driver_class com.ibm.as400.access.AS400JDBCDriver #hibernate.connection.url jdbc:as400://systemname ## Derby (not supported!) #hibernate.dialect org.hibernate.dialect.DerbyDialect #hibernate.connection.driver_class org.apache.derby.jdbc.EmbeddedDriver #hibernate.connection.username #hibernate.connection.password #hibernate.connection.url jdbc:derby:build/db/derby/hibernate;create=true ## Sybase #hibernate.dialect org.hibernate.dialect.SybaseDialect #hibernate.connection.driver_class com.sybase.jdbc2.jdbc.SybDriver #hibernate.connection.username sa #hibernate.connection.password sasasa #hibernate.connection.url jdbc:sybase:Tds:co3061835-a:5000/tempdb ## Mckoi SQL #hibernate.dialect org.hibernate.dialect.MckoiDialect #hibernate.connection.driver_class com.mckoi.JDBCDriver #hibernate.connection.url jdbc:mckoi:/// #hibernate.connection.url jdbc:mckoi:local://C:/mckoi1.0.3/db.conf #hibernate.connection.username admin #hibernate.connection.password nimda ## SAP DB #hibernate.dialect org.hibernate.dialect.SAPDBDialect #hibernate.connection.driver_class com.sap.dbtech.jdbc.DriverSapDB #hibernate.connection.url jdbc:sapdb://localhost/TST #hibernate.connection.username TEST #hibernate.connection.password TEST #hibernate.query.substitutions yes 'Y', no 'N' ## MS SQL Server #hibernate.dialect org.hibernate.dialect.SQLServerDialect #hibernate.connection.username sa #hibernate.connection.password sa ## JSQL Driver #hibernate.connection.driver_class com.jnetdirect.jsql.JSQLDriver #hibernate.connection.url jdbc:JSQLConnect://1E1/test ## JTURBO Driver #hibernate.connection.driver_class com.newatlanta.jturbo.driver.Driver #hibernate.connection.url jdbc:JTurbo://1E1:1433/test ## WebLogic Driver #hibernate.connection.driver_class weblogic.jdbc.mssqlserver4.Driver #hibernate.connection.url jdbc:weblogic:mssqlserver4:1E1:1433 ## Microsoft Driver (not recommended!) #hibernate.connection.driver_class com.microsoft.jdbc.sqlserver.SQLServerDriver #hibernate.connection.url jdbc:microsoft:sqlserver://1E1;DatabaseName=test;SelectMethod=cursor ## The New Microsoft Driver #hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver #hibernate.connection.url jdbc:sqlserver://localhost ## jTDS (since version 0.9) #hibernate.connection.driver_class net.sourceforge.jtds.jdbc.Driver #hibernate.connection.url jdbc:jtds:sqlserver://1E1/test ## Interbase #hibernate.dialect org.hibernate.dialect.InterbaseDialect #hibernate.connection.username sysdba #hibernate.connection.password masterkey ## DO NOT specify hibernate.connection.sqlDialect ## InterClient #hibernate.connection.driver_class interbase.interclient.Driver #hibernate.connection.url jdbc:interbase://localhost:3060/C:/firebird/test.gdb ## Pure Java #hibernate.connection.driver_class org.firebirdsql.jdbc.FBDriver #hibernate.connection.url jdbc:firebirdsql:localhost/3050:/firebird/test.gdb ## Pointbase #hibernate.dialect org.hibernate.dialect.PointbaseDialect #hibernate.connection.driver_class com.pointbase.jdbc.jdbcUniversalDriver #hibernate.connection.url jdbc:pointbase:embedded:sample #hibernate.connection.username PBPUBLIC #hibernate.connection.password PBPUBLIC ## Ingres ## older versions (before Ingress 2006) #hibernate.dialect org.hibernate.dialect.IngresDialect #hibernate.connection.driver_class ca.edbc.jdbc.EdbcDriver #hibernate.connection.url jdbc:edbc://localhost:II7/database #hibernate.connection.username user #hibernate.connection.password password ## Ingres 2006 or later #hibernate.dialect org.hibernate.dialect.IngresDialect #hibernate.connection.driver_class com.ingres.jdbc.IngresDriver #hibernate.connection.url jdbc:ingres://localhost:II7/database;CURSOR=READONLY;auto=multi #hibernate.connection.username user #hibernate.connection.password password ## Mimer SQL #hibernate.dialect org.hibernate.dialect.MimerSQLDialect #hibernate.connection.driver_class com.mimer.jdbc.Driver #hibernate.connection.url jdbc:mimer:multi1 #hibernate.connection.username hibernate #hibernate.connection.password hibernate ## InterSystems Cache #hibernate.dialect org.hibernate.dialect.Cache71Dialect #hibernate.connection.driver_class com.intersys.jdbc.CacheDriver #hibernate.connection.username _SYSTEM #hibernate.connection.password SYS #hibernate.connection.url jdbc:Cache://127.0.0.1:1972/HIBERNATE ################################# ### Hibernate Connection Pool ### ################################# hibernate.connection.pool_size 1 ########################### ### C3P0 Connection Pool### ########################### #hibernate.c3p0.max_size 2 #hibernate.c3p0.min_size 2 #hibernate.c3p0.timeout 5000 #hibernate.c3p0.max_statements 100 #hibernate.c3p0.idle_test_period 3000 #hibernate.c3p0.acquire_increment 2 #hibernate.c3p0.validate false ############################## ### Proxool Connection Pool### ############################## ## Properties for external configuration of Proxool hibernate.proxool.pool_alias pool1 ## Only need one of the following #hibernate.proxool.existing_pool true #hibernate.proxool.xml proxool.xml #hibernate.proxool.properties proxool.properties ################################# ### Plugin ConnectionProvider ### ################################# ## use a custom ConnectionProvider (if not set, Hibernate will choose a built-in ConnectionProvider using hueristics) #hibernate.connection.provider_class org.hibernate.connection.DriverManagerConnectionProvider #hibernate.connection.provider_class org.hibernate.connection.DatasourceConnectionProvider #hibernate.connection.provider_class org.hibernate.connection.C3P0ConnectionProvider #hibernate.connection.provider_class org.hibernate.connection.ProxoolConnectionProvider ####################### ### Transaction API ### ####################### ## Enable automatic flush during the JTA beforeCompletion() callback ## (This setting is relevant with or without the Transaction API) #hibernate.transaction.flush_before_completion ## Enable automatic session close at the end of transaction ## (This setting is relevant with or without the Transaction API) #hibernate.transaction.auto_close_session ## the Transaction API abstracts application code from the underlying JTA or JDBC transactions #hibernate.transaction.factory_class org.hibernate.transaction.JTATransactionFactory #hibernate.transaction.factory_class org.hibernate.transaction.JDBCTransactionFactory ## to use JTATransactionFactory, Hibernate must be able to locate the UserTransaction in JNDI ## default is java:comp/UserTransaction ## you do NOT need this setting if you specify hibernate.transaction.manager_lookup_class #jta.UserTransaction jta/usertransaction #jta.UserTransaction javax.transaction.UserTransaction #jta.UserTransaction UserTransaction ## to use the second-level cache with JTA, Hibernate must be able to obtain the JTA TransactionManager #hibernate.transaction.manager_lookup_class org.hibernate.transaction.JBossTransactionManagerLookup #hibernate.transaction.manager_lookup_class org.hibernate.transaction.WeblogicTransactionManagerLookup #hibernate.transaction.manager_lookup_class org.hibernate.transaction.WebSphereTransactionManagerLookup #hibernate.transaction.manager_lookup_class org.hibernate.transaction.OrionTransactionManagerLookup #hibernate.transaction.manager_lookup_class org.hibernate.transaction.ResinTransactionManagerLookup ############################## ### Miscellaneous Settings ### ############################## ## print all generated SQL to the console #hibernate.show_sql true ## format SQL in log and console hibernate.format_sql true ## add comments to the generated SQL #hibernate.use_sql_comments true ## generate statistics #hibernate.generate_statistics true ## auto schema export #hibernate.hbm2ddl.auto create-drop #hibernate.hbm2ddl.auto create #hibernate.hbm2ddl.auto update #hibernate.hbm2ddl.auto validate ## specify a default schema and catalog for unqualified tablenames #hibernate.default_schema test #hibernate.default_catalog test ## enable ordering of SQL UPDATEs by primary key #hibernate.order_updates true ## set the maximum depth of the outer join fetch tree hibernate.max_fetch_depth 1 ## set the default batch size for batch fetching #hibernate.default_batch_fetch_size 8 ## rollback generated identifier values of deleted entities to default values #hibernate.use_identifier_rollback true ## enable bytecode reflection optimizer (disabled by default) #hibernate.bytecode.use_reflection_optimizer true ##################### ### JDBC Settings ### ##################### ## specify a JDBC isolation level #hibernate.connection.isolation 4 ## enable JDBC autocommit (not recommended!) #hibernate.connection.autocommit true ## set the JDBC fetch size #hibernate.jdbc.fetch_size 25 ## set the maximum JDBC 2 batch size (a nonzero value enables batching) #hibernate.jdbc.batch_size 5 #hibernate.jdbc.batch_size 0 ## enable batch updates even for versioned data hibernate.jdbc.batch_versioned_data true ## enable use of JDBC 2 scrollable ResultSets (specifying a Dialect will cause Hibernate to use a sensible default) #hibernate.jdbc.use_scrollable_resultset true ## use streams when writing binary types to / from JDBC hibernate.jdbc.use_streams_for_binary true ## use JDBC 3 PreparedStatement.getGeneratedKeys() to get the identifier of an inserted row #hibernate.jdbc.use_get_generated_keys false ## choose a custom JDBC batcher # hibernate.jdbc.factory_class ## enable JDBC result set column alias caching ## (minor performance enhancement for broken JDBC drivers) # hibernate.jdbc.wrap_result_sets ## choose a custom SQL exception converter #hibernate.jdbc.sql_exception_converter ########################## ### Second-level Cache ### ########################## ## optimize cache for minimal "puts" instead of minimal "gets" (good for clustered cache) #hibernate.cache.use_minimal_puts true ## set a prefix for cache region names hibernate.cache.region_prefix hibernate.test ## disable the second-level cache #hibernate.cache.use_second_level_cache false ## enable the query cache #hibernate.cache.use_query_cache true ## store the second-level cache entries in a more human-friendly format #hibernate.cache.use_structured_entries true ## choose a cache implementation #hibernate.cache.region.factory_class org.hibernate.cache.infinispan.InfinispanRegionFactory #hibernate.cache.region.factory_class org.hibernate.cache.infinispan.JndiInfinispanRegionFactory #hibernate.cache.region.factory_class org.hibernate.cache.internal.EhCacheRegionFactory #hibernate.cache.region.factory_class org.hibernate.cache.internal.SingletonEhCacheRegionFactory hibernate.cache.region.factory_class org.hibernate.cache.internal.NoCachingRegionFactory ## choose a custom query cache implementation #hibernate.cache.query_cache_factory ############ ### JNDI ### ############ ## specify a JNDI name for the SessionFactory #hibernate.session_factory_name hibernate/session_factory ## Hibernate uses JNDI to bind a name to a SessionFactory and to look up the JTA UserTransaction; ## if hibernate.jndi.* are not specified, Hibernate will use the default InitialContext() which ## is the best approach in an application server #file system #hibernate.jndi.class com.sun.jndi.fscontext.RefFSContextFactory #hibernate.jndi.url file:/ #WebSphere #hibernate.jndi.class com.ibm.websphere.naming.WsnInitialContextFactory #hibernate.jndi.url iiop://localhost:900/
proxool.xml 是一个配置文件,用于配置 Proxool 数据库连接池。Proxool 是一个开源的 Java 数据库连接池,它允许应用程序在运行时动态地管理数据库连接,以提高应用程序的性能和可靠性。 proxool.xml 文件包含以下信息: 1. 数据库驱动程序的类名和连接字符串。 2. 数据库连接池的配置信息,例如最大连接数、最小连接数、最大空闲时间等。 3. 用户名和密码等连接数据库所需的凭证信息。 proxool.xml 文件的示例代码如下: ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE proxool PUBLIC "-//mikebob.net/proxool//DTD Proxool//EN" "proxool.dtd"> <proxool> <driver-url>jdbc:mysql://localhost/mydb</driver-url> <driver-class>com.mysql.jdbc.Driver</driver-class> <user>myuser</user> <password>mypassword</password> <maximum-connection-count>50</maximum-connection-count> <minimum-connection-count>10</minimum-connection-count> <simultaneous-build-throttle>20</simultaneous-build-throttle> <house-keeping-test-sql>select 1</house-keeping-test-sql> <house-keeping-sleep-time>30000</house-keeping-sleep-time> </proxool> ``` 其,`driver-url`、`driver-class`、`user`、`password` 分别表示数据库连接字符串、数据库驱动程序的类名、用户名和密码;`maximum-connection-count`、`minimum-connection-count` 分别表示连接池的最大连接数和最小连接数;`simultaneous-build-throttle` 表示同时建立连接的最大数目;`house-keeping-test-sql` 表示定期检查连接是否可用的 SQL 语句;`house-keeping-sleep-time` 表示定期检查连接的时间间隔。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值