盡人事而順天命

          關(guān)注 esb , soa ,設(shè)計模式,快速組件式開發(fā)

             :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
            6 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks
          沒有想到會碰到這樣的一個問題,百思不得其解,貼出來希望哪位也在使用 db2? type2 app jdbc 的兄弟幫忙分析一下: 

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

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

          <insert?id="ppl_t1.insert"?parameterClass="com.surekam.ppl.dao.test.PPLT1">
          ????????asfafdafsdafafsd?values?(#projId#,#name#);
          </insert>
          也就是說,一個完全不合法的 sql 語句,但是,在執(zhí)行的時候, db2 jdbc 居然不報錯!!查找到 ibatis 的 sql 執(zhí)行部分的代碼: 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 在執(zhí)行的時候就是不 拋出 SQLException ,而是處理成 SQLWarning ,可以通過 getWarning 取到錯誤信息. 

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

          posted on 2006-04-03 10:11 boss_ch 閱讀(647) 評論(1)  編輯  收藏 所屬分類: 技術(shù)隨筆

          Feedback

          # re: 關(guān)于 db2 jdbc 百思不得其解的問題 2006-04-27 17:52 兵臨城下
          看不懂!呵呵  回復(fù)  更多評論
            

          主站蜘蛛池模板: 湾仔区| 阜阳市| 沙湾县| 应城市| 宁化县| 江北区| 梁山县| 营口市| 河北区| 锡林郭勒盟| 海安县| 华安县| 嘉禾县| 汝南县| 钦州市| 星座| 中超| 温宿县| 剑阁县| 榕江县| 道孚县| 丹江口市| 罗田县| 阿荣旗| 仲巴县| 封丘县| 江西省| 枞阳县| 澄江县| 沂南县| 吉木萨尔县| 雷州市| 建阳市| 贵州省| 石首市| 阿拉尔市| 舟山市| 内黄县| 德昌县| 牟定县| 常熟市|