Ibatis 连接 Timesten 的一个诡异问题

近日,调试ibatis(版本:ibatis-2.3.4.726.jar)连接Timesten(TimesTen release 11.2.2.4.1)(驱动版本 ttjdbc6.jar); 数据源连接池 为c3p0(版本号为 C3p0-0.9.2.1)

Spring 框架(版本 Spring2.5.6)

在调用存储过程中,使用 super.getSqlMapClientTemplate().queryForObject(); 时,线程挂起,在里面做死循环处理。CPU 可飚100%。(注,连接oracle数据库可以执行)

使用super.getSqlMapClientTemplate().update()或是 super.getSqlMapClientTemplate().insert()时,可以执行成功。


后来下载了这些包的源码,最后问题定位在了 Ibatis 的 SqlExecutor 类中的

private ResultSet getFirstResultSet(StatementScope scope, Statement stmt) throws SQLException {
    ResultSet rs = null;
    boolean hasMoreResults = true;
    while (hasMoreResults) {
      rs = stmt.getResultSet();
      if (rs != null) {
        break;
      }
      hasMoreResults = moveToNextResultsIfPresent(scope, stmt);
    }
    return rs;
  }


 private boolean moveToNextResultsIfPresent(StatementScope scope, Statement stmt) throws SQLException {
    boolean moreResults;
    // This is the messed up JDBC approach for determining if there are more results
    moreResults = !(((moveToNextResultsSafely(scope, stmt) == false) && (stmt.getUpdateCount() == -1)));
    return moreResults;
  }

在这段的stmt.getUpdateCount() == -1 判断为false。


对比oracle  驱动执行 与timesten 驱动执行,两者区别就在这个地方。oracle 返回true。可结束while 循环。

找到timesten驱动源码:执行这段

public synchronized int getUpdateCount()
/*      */     throws SQLException
/*      */   {
/*  953 */     if (Logger.isTracingOn()) {
/*  954 */       Logger.logln("*Statement.getUpdateCount()");
/*      */     }
/*      */
/*  957 */     validateStatement();
/*      */
/*  962 */     if (!this.moreResults) {
/*  963 */       return -1;
/*      */     }
/*      */
/*  967 */     int i = -1;
/*      */
/*  969 */     if (!this.hasResultSet) {
/*  970 */       i = getRowCount();
/*      */     }
/*      */     else {
/*  973 */       setWarning(new SQLWarning("Statement has a ResultSet"));
/*      */     }
/*      */
/*  976 */     return i;
/*      */   }


int getRowCount()
/*      */     throws SQLException
/*      */   {
/* 1737 */     int i = 0;
/*      */     try
/*      */     {
/* 1740 */       i = this.OdbcApi.SQLRowCount(this.hStmt.getValue());
/*      */     }
/*      */     catch (JdbcOdbcSQLWarning localJdbcOdbcSQLWarning)
/*      */     {
/* 1746 */       BigDecimal localBigDecimal = (BigDecimal)localJdbcOdbcSQLWarning.value;
/* 1747 */       i = localBigDecimal.intValue();
/*      */     }
/*      */
/* 1750 */     return i;
/*      */   }

就是上述这句正常执行返回了0.


自此,想来应该是两者驱动程序处理这段代码之间的差异问题。至于其中是否可配置什么参数,避免。还没找到相关资料。

如果看到这里的朋友,有什么办法解决的,可以留个言。一起学习。谢谢

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值