0

我设置了 maxactive=20,但是当我执行 show processlist 时,我显示了 30 多个连接,如下所示:

109051 | root | localhost:33203     | hibernate   | Sleep   |    4 |       | N

这是我的设置:

mysql5.hibernate.cfg.xml

<property name="cache.provider_class">org.hibernate.cache.EhCacheProvider</property><property name="hibernate.generate_statistics">true</property>
<property name="hibernate.cache.use_query_cache">true</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="connection.pool_size">10</property>
<property name="show_sql">false</property>
<property name="hibernate.jdbc.use_streams_for_binary">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property><property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idle_test_period">10</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">75</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1</property>
<property name="hibernate.c3p0.testConnectionOnCheckout">true</property>

上下文.xml

<Context path="/pentaho" docbase="webapps/pentaho/">
<Resource name="jdbc/Hibernate" auth="Container" type="javax.sql.DataSource" factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5" maxWait="10000" username="user" password="password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/hibernate" validationQuery="select 1"/>
<Resource name="jdbc/Quartz" auth="Container" type="javax.sql.DataSource" factory="org.apache.commons.dbcp.BasicDataSourceFactory" maxActive="20" maxIdle="5" maxWait="10000" username="user" password="password" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/quartz" validationQuery="select 1"/>
</Context>

我该如何解决这个问题?最良好的问候

4

1 回答 1

1

hibernate.c3p0.max_size 这是池中的最大连接数。如果此数字用尽,则在运行时引发异常。

你有 :

<property name="hibernate.c3p0.max_size">75</property>

所以将其更改为:

<property name="hibernate.c3p0.max_size">20</property>
于 2013-05-22T12:22:58.510 回答