1、在使用c3p0连接池时候,重启服务器以及关闭数据连接时候控制台会打印出这样的日志信息
java.lang.Exception: DEBUG STACK TRACE for PoolBackedDataSource.close().
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.close(AbstractPoolBackedDataSource.java:417)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)。。。。。
ava.lang.Exception: DEBUG -- CLOSE BY CLIENT STACK TRACE
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:566)
at com.mchange.v2.c3p0.impl.NewPooledConnection.close(NewPooledConnection.java:234)
at com.mchange.v2.resourcepool.BasicResourcePool$1DestroyResourceTask.run(BasicResourcePool.java:964)
at com.mchange.v2.resourcepool.BasicResourcePool.destroyResource(BasicResourcePool.java:989)
at com.mchange.v2.resourcepool.BasicResourcePool.access$100(BasicResourcePool.java:32)
at com.mchange.v2.resourcepool.BasicResourcePool$5.run(BasicResourcePool.java:1174)
网上搜索了一下,又看了c3p0的源码明白了原因,代码:
if (Debug.DEBUG && Debug.TRACE == Debug.TRACE_MAX && logger.isLoggable(MLevel.FINEST))
{
logger.log(MLevel.FINEST,
this.getClass().getName() + '@' + Integer.toHexString( System.identityHashCode( this ) ) +
" has been closed. ",
new Exception("DEBUG STACK TRACE for PoolBackedDataSource.close()."));
}
由于日志设为debug模式,在关闭数据连接及重启服务时候就会打印出这样的信息,实际上是没有错的,但用new Exception打印信息这个太坑爹了,害了不少人花时间去找这个错误,改天把这个代码给改掉。