DEBUG -- CLOSE BY CLIENT STACK TRACE

在使用C3P0数据库连接池时遇到DEBUG -- CLOSE BY CLIENT STACK TRACE异常。通过调整日志级别可以避免,但会丢失其他DEBUG信息。尝试修改C3P0配置,特别是增大maxIdleTime值,如设置为3600秒,可解决异常。此设置表示最大空闲时间,超过时间未使用的连接会被丢弃,有助于减轻连接池负载。
部署运行你感兴趣的模型镜像

第一次写博文,完全是属于菜鸟级别,写的不好之处还望各路大神多多指教,小子感激不尽。

最经开发一个项目使用了C3P0数据库连接池,发现了有这样一个Exception:

java.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:646)
at com.mchange.v2.c3p0.impl.NewPooledConnection.closeMaybeCheckedOut(NewPooledConnection.java:259)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.destroyResource(C3P0PooledConnectionPool.java:619)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:1024)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:648)

网上查了很多资料,差不不多都是说这个错误错误不会影响C3PO的使用,最简单的方法时提高日志输出级别,我自己用的log4j,把日子输出级别从DEBUG提到INFO级别就可以了。这样是能够解决问题,但是在开发当中自己定义的那些logger.debug信息也一样无法显示了。

网上也有很多分析原因的文章和解决方法,如http://hi.baidu.com/xhr8334/item/7e5a6f5326aa02d5d48bacca

但貌似都不适合我自己的这个项目。后来我尝试修改一些C3P0de配置常数,发现这个异常就消失了,

就是maxIdleTime的值设的稍微大一些,如:<property name="maxIdleTime" value="3600"></property>

这个是指最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值为 0

同时为了减轻连接池的负载,比如连接池中连接数因为某次数据访问高峰导致创建了很多数据连接  
但是后面的时间段需要的数据库连接数很少,则此时连接池完全没有必要维护那么多的连接,所以有必要将  
断开丢弃掉一些连接来减轻负载,必须小于maxIdleTime。配置不为0,则会将连接池中的连接数量保持到minPoolSize。

还可以设置<property name="maxIdleTimeExcessConnections" value="1800"/>(该设置和上述异常无关,即不设置也不会抛出上述异常)

原理不是非常清楚,也不敢夸大其词。希望能对各位朋友有用。


您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

> Task :app:compileDebugJavaWithJavac FAILED FAILURE: Build completed with 5 failures. 1: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeDebugJavaResource'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform httpclient-osgi-4.5.14.jar to match attributes {artifactType=android-java-res, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar > Failed to transform httpclient-win-4.5.14.jar to match attributes {artifactType=android-java-res, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar > Failed to transform httpcore-4.4.16.jar to match attributes {artifactType=android-java-res, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 2: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:checkDebugDuplicateClasses'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform httpclient-osgi-4.5.14.jar to match attributes {artifactType=enumerated-runtime-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar > Failed to transform httpclient-win-4.5.14.jar to match attributes {artifactType=enumerated-runtime-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar > Failed to transform httpcore-4.4.16.jar to match attributes {artifactType=enumerated-runtime-classes, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 3: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:desugarDebugFileDependencies'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform httpclient-osgi-4.5.14.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar > Failed to transform httpclient-win-4.5.14.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar > Failed to transform httpcore-4.4.16.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 4: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:mergeDebugNativeLibs'. > Could not resolve all files for configuration ':app:debugRuntimeClasspath'. > Failed to transform httpclient-osgi-4.5.14.jar to match attributes {artifactType=android-jni, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for ExtractJniTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar. > C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar > Failed to transform httpclient-win-4.5.14.jar to match attributes {artifactType=android-jni, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for ExtractJniTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar. > C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar > Failed to transform httpcore-4.4.16.jar to match attributes {artifactType=android-jni, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for ExtractJniTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar. > C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== 5: Task failed with an exception. ----------- * What went wrong: Execution failed for task ':app:compileDebugJavaWithJavac'. > Could not resolve all files for configuration ':app:debugCompileClasspath'. > Failed to transform httpclient-osgi-4.5.14.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-osgi-4.5.14.jar > Failed to transform httpclient-win-4.5.14.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpclient-win-4.5.14.jar > Failed to transform httpcore-4.4.16.jar to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}. > Execution failed for IdentityTransform: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar. > File/directory does not exist: C:\android\Notesmaster\httpcomponents-client-4.5.14-bin\lib\httpcore-4.4.16.jar * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. > Run with --scan to get full insights. > Get more help at https://help.gradle.org. ============================================================================== BUILD FAILED in 2m 7s 26 actionable tasks: 26 executed
05-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值