【发布时间】:2016-07-14 01:06:12
【问题描述】:
我有一个加载了 DataSource 的 tomcat 8 服务器。我想知道是否可以将这个 DataSource 与 c3p0 连接池管理结合使用。到目前为止,这是我尝试过的。
上下文.xml
<Context>
...
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxIdle="30" maxTotal="100" maxWaitMillis="10000"
name="jdbc/store" password="text" type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/db" username="user"/>
</Context>
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="hibernate.connection.datasource">
java:comp/env/jdbc/store
</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>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
...more stuff
问题是mysql在服务器启动后只显示一个进程
【问题讨论】: