簡體   English   中英

Hibernate c3p0配置沒有影響

[英]Hibernate c3p0 configuration has no affect

我正在嘗試將c3p0連接池添加到我們現有的休眠配置中。 但是它沒有任何影響,休眠狀態仍使用默認池。 單獨使用Hibernate Configuration可以正常工作,所以我絕對可以確定它沒有問題。

想知道這里有人可以指出我的錯誤還是建議我如何調試問題?

我不使用Spring框架。

<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">com.ibm.db2.jcc.DB2Driver</property>
    <property name="hibernate.connection.password">passwd</property>
    <property name="hibernate.connection.url">jdbc:db2://server:port/database</property>
    <property name="hibernate.connection.username">username</property>

    <property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <property name="hibernate.connection.autocommit">false</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <property name="hibernate.default_schema">DB Schema</property>
    <property name="hibernate.dialect">org.hibernate.dialect.DB2Dialect</property>
    <property name="hibernate.format_sql">false</property>
    <property name="hibernate.max_fetch_depth">4</property>
    <property name="hibernate.search.autoregister_listeners">false</property>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.connection.isolation">1</property>
    <property name="hibernate.jdbc.batch_size">50</property>

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">3000</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">900</property>

<mapping resource="table.hbm.xml" />

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

這是我有的罐子:

hibernate3.jar
hibernate-c3p0-3.5.0-Final.jar

日志中的語句:

hibernate.cfg.Environment - Hibernate 3.5.0-Final
INFO  ManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
INFO  ManagerConnectionProvider - Hibernate connection pool size: 20

嘗試從c3p0配置連接提供程序類。

<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

另外,最好添加休眠配置文檔類型,這將有助於查找任何錯別字。

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

更新您需要在類路徑中包括mchange庫。 鏈接可能對您有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM