gpt4 book ai didi

java - GenericJDBCException 被 try/catch block 的错误部分捕获

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:52:20 24 4
gpt4 key购买 nike

我有这段代码:

        } 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 异常时,它就像一个通用异常一样被捕获了!

为什么?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 异常:

org.springframework.transaction.CannotCreateTransactionException:无法为事务打开 Hibernate Session;嵌套异常是 org.hibernate.exception.GenericJDBCException: 无法打开连接

关于java - GenericJDBCException 被 try/catch block 的错误部分捕获,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16677808/

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