2014-03-25 34 views
2

我想上传图片(逐个)使用c3p0连接池,但我的jdbc类型4驱动程序(连接到MySQL)不断关闭连接。我已经看到mysql配置中的最大超时设置为300秒。这是我的持久性xml如何使用c3p0。连接关闭后,不允许任何操作。连接被驱动程序隐式关闭。 C3P0

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" 
    scope="singleton" destroy-method="close"> 
    <property name="driverClass" value="...." /> 
    <property name="jdbcUrl" value="...." /> 
    <property name="user" value="....." /> 
    <property name="password" value="...." /> 
    <property name="initialPoolSize" value="10" /> 
    <property name="minPoolSize" value="5" /> 
    <property name="maxPoolSize" value="20" /> 
    <property name="maxIdleTime" value="5" /> 
    <property name="autoCommitOnClose" value="false" /> 
</bean> 

有人可以解释究竟是什么导致驱动程序隐式关闭连接。 另外,我该如何解决这个问题?

以下是错误消息我得到:

19:01:45,504 WARN NewPooledConnection:486 - [c3p0] A PooledConnection that has already signalled a Connection error is still in use! 

19:01:45,505 WARN NewPooledConnection:487 - [c3p0] Another error has occurred [ 

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver. ] which will not be reported to listeners! 

com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed by the driver. 
+0

我认为这个问题是更多的[超级用户](http://www.superuser.com )。 – PlasmaPower

+0

@PlasmaPower,它几乎属于这里。 – Reddy

+0

@Reddy这是关于驱动程序,这里唯一的代码是XML。 [帮助中心](http://stackoverflow.com/help/on-topic)表示,问题应该是:特定的**编程**问题(否),软件算法(否),常用软件工具由程序员(类似的,但这是一个驱动程序错误),或实际的,可回答的问题,这是**软件**开发(否)所特有的。 [超级用户的帮助中心](http://superuser.com/help/on-topic)表示问题应该是:计算机硬件,计算机软件(适用于此)或个人和家庭计算机网络。 – PlasmaPower

回答

3

你可以改变这

<property name="maxIdleTime" value="0" /> //0 = never expire 
+0

即使我的问题没有解决,对于我所问的问题,这是最合适的解决方案。也许我还有其他一些问题,这就是为什么我的错误依然存在。 –

相关问题