我在我的应用程序中使用JBOSS 7.1 Web服务器。我配置了JBOSS连接池并将其用于JDBC连接。我也在我的应用程序中使用hibernate。我想知道hibernate是否也使用这个连接池,或者我需要为hibernate配置其他连接池(例如c3p0)?
答案 0 :(得分:1)
C3P0连接池
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
hibernate.c3p0.min_size - 池中的最小JDBC连接数。 Hibernate默认值:1 hibernate.c3p0.max_size - 池中的最大JDBC连接数。 Hibernate默认值:100 hibernate.c3p0.timeout - 从池中删除空闲连接时(第二个)。 Hibernate默认值:0,永不过期。 hibernate.c3p0.max_statements - 将缓存预准备语句的数量。提高性能。 Hibernate默认值:0,禁用缓存。 hibernate.c3p0.idle_test_period - 自动验证连接之前的空闲时间(以秒为单位)。 Hibernate默认值:0
http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html/ch01.html
答案 1 :(得分:0)
的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">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:schema</property>
<property name="hibernate.connection.username">user</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">schema</property>
<property name="show_sql">true</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
hibernate.c3p0.min_size – Minimum number of JDBC connections in the pool. Hibernate default: 1
hibernate.c3p0.max_size – Maximum number of JDBC connections in the pool. Hibernate default: 100
hibernate.c3p0.timeout – When an idle connection is removed from the pool (in second). Hibernate default: 0, never expire.
hibernate.c3p0.max_statements – Number of prepared statements will be cached. Increase performance. Hibernate default: 0 , caching is disable.
hibernate.c3p0.idle_test_period – idle time in seconds before a connection is automatically validated. Hibernate default: 0
更多详情请参阅link