【问题标题】:How to capture Sybase RAISERROR in Mybatis-Spring?Mybatis-Spring中如何捕获Sybase RAISERROR?
【发布时间】:2012-07-27 16:25:50
【问题描述】:

我正在尝试使用 RAISERROR 从 Sybase 中的存储过程中捕获我的 Java 代码中的错误消息,但没有捕获任何内容,即使当我直接调用 proc 时我可以看到错误被抛出。

我理解Mybatis-Spring

将 MyBatis 异常翻译成 Spring DataAccessException

所以我已经编写了我的 Mapper 类:

void insertData(Data toInsert) throws Exception, DataAccessException;

我试图捕捉这两个异常,但没有捕捉到任何东西。

有人有什么想法吗?

谢谢, 斯蒂芬

【问题讨论】:

    标签: spring sybase mybatis raiserror


    【解决方案1】:

    我知道怎么做:

    try {
        myMapper.insertData(data);
    }
    catch (org.springframework.jdbc.UncategorizedSQLException e) {
        Throwable ee = use.getCause();
        // getMessage on chained exception gets message from RAISERROR
        log.error(ee.getMessage(), e);
    }
    

    干杯, 斯蒂芬

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      • 1970-01-01
      • 1970-01-01
      • 2023-02-16
      • 1970-01-01
      • 2013-10-22
      • 2010-12-06
      相关资源
      最近更新 更多