<session-factory>
<property name="hibernate.connection.provider_class ">
org.hibernate.connection.C3P0ConnectionProvider
</property>
<property name="hibernate.c3p0.max_size ">15</property>
<property name="hibernate.c3p0.min_size ">1</property>
<property name="hibernate.c3p0.timeout ">1800</property>
<property name="hibernate.c3p0.max_statements ">1000</property>
<property name="hibernate.c3p0.idle_test_period ">
30000
</property> <property name="hibernate.c3p0.acquire_increment ">1</property>
<property name="hibernate.c3p0.validate ">true</property>
<property name="hibernate.jdbc.batch_size">4</property>
<property name="hibernate.max_fetch_depth">0</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<property name="hibernate.format_sql">true</property> <property name="connection.url">
jdbc:postgresql://localhost:5432/exam
</property>
<property name="connection.username">postgres</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">
org.postgresql.Driver
</property>
<property name="dialect">
org.hibernate.dialect.PostgreSQLDialect
</property> <!--<property name="hibernate.connection.datasource">
java:/com/env/jdbc/post_exam
</property>-->
<property name="hibernate.current_session_context_class">
thread
</property>
<property
name="hibernate.transaction.flush_before_completion">
true
</property>
<property name="hibernate.transaction.auto_close_session">
false
</property>
<mapping
resource="......." />
</session-factory>如上配置,但是运行日志始终显示
INFO - Using Hibernate built-in connection pool (not for production use!)
INFO - Hibernate connection pool size: 20请问,怎么样才能配上c3p0呢,谢谢啦

解决方案 »

  1.   

    c3p0为open source的JDBC连接池,随hibernate一起发布。本文介绍了怎么在hibernate里配置使用c3p0。 
    c3p0连接池的配置非常简单,只需要在hibernate.cfg.xml里增加:        <!-- configuration pool -->
            <property name="c3p0.acquire_increment">1</property>
            <property name="c3p0.idle_test_period">100</property> <!-- seconds -->
            <property name="c3p0.max_size">5</property>
            <property name="c3p0.max_statements">0</property>
            <property name="c3p0.min_size">2</property>
            <property name="c3p0.timeout">90</property> <!-- seconds -->另外,还需要在CLASS_PATH里加上c3p0-x.x.x.jar文件(x.x.x为版本号),c3p0-x.x.x.jar文件随hibernate一起发布,你可以在其lib目录下找到该文件。配置好之后,hibernate便会自动使用c3p0的连接池:C3P0ConnectionProvider
      

  2.   

    http://blog.csdn.net/fenglibing/archive/2009/04/22/4100272.aspx
      

  3.   

    INFO - Using Hibernate built-in connection pool (not for production use!) 
    INFO - Hibernate connection pool size: 20 ?
    这个是信息嘛,不是异常啊,贴异常瞧瞧