由于 Spring 中的 SQLException 导致 UndeclaredThrowableException +伊巴蒂斯?

发布于 2024-09-02 04:05:56 字数 926 浏览 2 评论 0原文

当我输入错误的 SQL 驱动程序名称或数据库服务器脱机时,我会收到以下异常,基本上是任何 SQLException。

我无法确定 UndeclaredThrowableException 来自何处。 SqlMapClientTemplate 中的第 194 行是这样的:

logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation");

这是跟踪:

    java.lang.reflect.UndeclaredThrowableException
        $Proxy59.toString(Unknown Source)
    java.lang.String.valueOf(Unknown Source)
    java.lang.StringBuffer.append(Unknown Source)
    org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
    org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)

我的一些阅读指向某种类型的类加载问题?我不知道 $Proxy 是在哪里引入的?

I am getting the following exception when I typo the SQL driver name or the database server is offline, basically any SQLException.

I can't determine where the UndeclaredThrowableException is coming from. Line 194 in SqlMapClientTemplate is this:

logger.debug("Obtained JDBC Connection [" + springCon + "] for iBATIS operation");

Here is the trace:

    java.lang.reflect.UndeclaredThrowableException
        $Proxy59.toString(Unknown Source)
    java.lang.String.valueOf(Unknown Source)
    java.lang.StringBuffer.append(Unknown Source)
    org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:194)
    org.springframework.orm.ibatis.SqlMapClientTemplate.executeWithListResult(SqlMapClientTemplate.java:249)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:296)
    org.springframework.orm.ibatis.SqlMapClientTemplate.queryForList(SqlMapClientTemplate.java:290)

some of my reading points to some type of class loading problem? I can't figure out where the $Proxy is getting introduced?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2024-09-09 04:05:56

$Proxy59 类必须是 springCon 变量的类型。它是一个JDK代理类型,可能是Spring框架引入的,作为真实连接的包装器。我知道有一个池化连接提供程序,它返回通过代理抑制 close() 方法的连接(因为连接是池化的,调用 close 不是客户端的任务)。

也许代理的 toString() 方法的处理程序会抛出一个已检查的异常,这对于代理机制来说是可能的,但不允许。

Java 文档 说:

  • “如果由不可分配给接口方法的 throws 子句中声明的任何异常类型的调用引发检查异常,则代理实例上的方法调用将引发 UndeclaredThrowableException ,并使用以下异常构造:被调用方法抛出。”

您是否记录了任何其他异常(可能是在该异常之前),或者提到了异常原因?

The $Proxy59 class must be the type of the springCon variable. It is a JDK proxy type, probably introduced by the Spring framework, as a wrapper for the real connection. I know of a pooled connection provider that returns connections which suppress the close() method via a proxy (because the connection is pooled, calling close is not the client's task).

Maybe the proxy's handler for the toString() method throws a checked exception, which is possible with the proxy mechanics, but not allowed.

The Java Documentation says:

  • "If a checked exception is thrown by invoke that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException will be thrown by the method invocation on the proxy instance. The UndeclaredThrowableException will be constructed with the exception that was thrown by the invoke method."

Do you get any other exception logged, maybe directly before that, or mentioned as the exception cause?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文