gpt4 book ai didi

java - 连接关闭后不允许进行任何操作。连接已被驱动程序隐式关闭。 C3P0

转载 作者:行者123 更新时间:2023-11-29 01:58:06 25 4
gpt4 key购买 nike

我正在尝试使用 c3p0 连接池上传图像(一张一张),但我的 jdbc 类型 4 驱动程序(连接到 mysql)一直关闭连接。我看到mysql的配置中最大超时设置为300秒。这是我的持久性 xml 如何使用 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.

最佳答案

你能把这个改成

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

关于java - 连接关闭后不允许进行任何操作。连接已被驱动程序隐式关闭。 C3P0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22625681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com