java-GenericJDBCException被try / catch块的错误部分捕获
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java-GenericJDBCException被try / catch块的错误部分捕获,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1197字,纯文字阅读大概需要2分钟。
内容图文
![java-GenericJDBCException被try / catch块的错误部分捕获](/upload/InfoBanner/zyjiaocheng/658/fcd460f617324105970350e6a208f65c.jpg)
我有这段代码:
} catch (HibernateException e) {
loginAnswer = new LoginCustomerAreaAnswer(999);
//This function use the error code save inside loginAnswer
this.logOp.error(logsUtilities.logException(e, "HibernateException"));
} catch (Exception e) {
loginAnswer = new LoginCustomerAreaAnswer(997);
//This function use the error code save inside loginAnswer
this.logOp.error(logsUtilities.logException(e, "Exception"));
} finally {
return loginAnswer;
}
如您所见,我首先捕获了HibernateException类型异常,然后是通用异常.
但是,当我查看日志文件时,当我遇到org.hibernate.exception.GenericJDBCException异常时,它就像通用Exception一样被捕获!
为什么?GenericJDBCException它不是HibernateException的“儿子”吗?不必被HibernateException捕获吗?
这是我的日志文件的一个示例
2013-05-21 11:01:02 [Level: ERROR]*** Exception: Error code: 997 - Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
我真的迷失了,有人可以帮我吗?
解决方法:
最有可能您捕获了Spring Exception:
org.springframework.transaction.CannotCreateTransactionException:无法打开Hibernate Session进行事务处理.嵌套的异常是org.hibernate.exception.GenericJDBCException:无法打开连接
内容总结
以上是互联网集市为您收集整理的java-GenericJDBCException被try / catch块的错误部分捕获全部内容,希望文章能够帮你解决java-GenericJDBCException被try / catch块的错误部分捕获所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。