关于 数据库连接 An attempt by a client to checkout a Connection has timed out 问题解决

    异常日志信息:

 [2013-04-18 20:13:08] WARN  [http-pas-9999-20$161385442] (JDBCExceptionReporter.java:100) - SQL Error: 0, SQLState: null
 [2013-04-18 20:13:08] ERROR [http-pas-9999-20$161385442] (JDBCExceptionReporter.java:101) - An attempt by a client to checkout a Connection has timed out.
 [2013-04-18 20:13:08] WARN  [http-pas-9999-20$161385442] (JDBCExceptionReporter.java:100) - SQL Error: 0, SQLState: null
 [2013-04-18 20:13:08] ERROR [http-pas-9999-20$161385442] (JDBCExceptionReporter.java:101) - An attempt by a client to checkout a Connection has timed out.

 [2013-04-18 20:13:08] ERROR [http-pas-9999-20$161385442] (GetVideoFileMD5Servlet.java:60) - GetVideoFileMD5Servlet error null
 java.lang.NullPointerException
at com.hunthawk.framework.HibernateGenericController.executeQuerySQL(HibernateGenericController.java:652)
at com.hunthawk.reader.service.videoTask.impl.VideoTaskFileImplService.getTargetFileMd5(VideoTaskFileImplService.java:379)
at com.hunthawk.reader.service.videoTask.impl.VideoTaskFileImplService$$FastClassByCGLIB$$3d517436.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:700)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:635)
at com.hunthawk.reader.service.videoTask.impl.VideoTaskFileImplService$$EnhancerByCGLIB$$49109a1d.getTargetFileMd5(<generated>)
at com.hunthawk.reader.servlet.GetVideoFileMD5Servlet.process(GetVideoFileMD5Servlet.java:56)
at com.hunthawk.reader.servlet.GetVideoFileMD5Servlet.doGet(GetVideoFileMD5Servlet.java:33)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:114)

问题问下: 刚开是以为是数据库账号有问题,导致不能连接,但是重启服务器之后就可以了,系统跑一会之后,就会出现连接超时的问题,最后看了下代码

      代码如下:

         } catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if(rs != null){
rs.close();
}
if(smt != null){
smt.close();
}
if(conn != null){
conn.close();
}

} catch (Exception e) {
e.printStackTrace();
}
session.close();

       在finally 中关闭数据库连接,开始在finally中没有判断 rs,smt,conn 是否为空,直接关闭,后来发现有与查询的时候数据表名写错了,导致rs 对象为空,所以后面数据连接就没有关闭,这样创建的数据库连接越来越多,没有被释放,导致后面不能创建新的连接。

   


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值