盡人事而順天命

          關注 esb , soa ,設計模式,快速組件式開發

             :: 首頁 :: 聯系 :: 聚合  :: 管理
            6 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

          2006年4月3日 #

          沒有想到會碰到這樣的一個問題,百思不得其解,貼出來希望哪位也在使用 db2? type2 app jdbc 的兄弟幫忙分析一下: 

          使用 ibatis? sql map以及 dao 框架 ,使用 JTA 事務管理,在 websphere 5.1 以及 jboss 4.1 上測試,都出現以下的怪現象: 

          使用? sql map 執行 insert? 操作的時候, 聲明如下的 sql map:

          <insert?id="ppl_t1.insert"?parameterClass="com.surekam.ppl.dao.test.PPLT1">
          ????????asfafdafsdafafsd?values?(#projId#,#name#);
          </insert>
          也就是說,一個完全不合法的 sql 語句,但是,在執行的時候, db2 jdbc 居然不報錯!!查找到 ibatis 的 sql 執行部分的代碼: SqlExecutor 類的: 
           
          ?1public?int?executeUpdate(RequestScope?request,?Connection?conn,?String?sql,?Object[]?parameters)
          ?2??????throws?SQLException?{
          ?3????ErrorContext?errorContext?=?request.getErrorContext();
          ?4????errorContext.setActivity("executing?update");
          ?5????errorContext.setObjectId(sql);
          ?6
          ?7????PreparedStatement?ps?=?null;
          ?8????int?rows?=?0;
          ?9
          10????try?{
          11??????errorContext.setMoreInfo("Check?the?SQL?Statement?(preparation?failed).");
          12??????ps?=?conn.prepareStatement(sql);
          13
          14??????errorContext.setMoreInfo("Check?the?parameters?(set?parameters?failed).");
          15??????request.getParameterMap().setParameters(request,?ps,?parameters);
          16
          17??????errorContext.setMoreInfo("Check?the?statement?(update?failed).");
          18
          19??????ps.execute();
          20??????rows?=?ps.getUpdateCount();
          21????}

          22????finally?{
          23??????closeStatement(ps);
          24????}

          25
          26????return?rows;
          27??}


          其中并沒有什么特別的地方,可是? PrepardStatement 在執行的時候就是不 拋出 SQLException ,而是處理成 SQLWarning ,可以通過 getWarning 取到錯誤信息. 

          而直接自己寫一個測試,直接去測試這樣一個不合法的 sql ,是會拋出異常的.
          db2jdbc 的 bug ?? 還是其它哪里的環境設置?? 

          posted @ 2006-04-03 10:11 boss_ch 閱讀(639) | 評論 (1)編輯 收藏

          主站蜘蛛池模板: 上饶市| 吴川市| 临清市| 陇南市| 祁阳县| 德令哈市| 依兰县| 安龙县| 长宁县| 福贡县| 营山县| 蒙山县| 郓城县| 望江县| 屯留县| 台江县| 余姚市| 沙雅县| 南昌县| 温州市| 蒲城县| 旌德县| 浮山县| 南丹县| 黄骅市| 扎囊县| 上虞市| 思南县| 格尔木市| 滕州市| 手游| 大石桥市| 巩义市| 思南县| 开化县| 旺苍县| 通辽市| 建瓯市| 尉氏县| 平顶山市| 翁源县|