盡人事而順天命

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

             :: 首頁 :: 聯系 :: 聚合  :: 管理
            6 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks
          沒有想到會碰到這樣的一個問題,百思不得其解,貼出來希望哪位也在使用 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 on 2006-04-03 10:11 boss_ch 閱讀(639) 評論(1)  編輯  收藏 所屬分類: 技術隨筆

          Feedback

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

          主站蜘蛛池模板: 竹山县| 镇雄县| 滕州市| 汨罗市| 聊城市| 桃源县| 平乐县| 佛山市| 金沙县| 剑河县| 浙江省| 安远县| 邯郸县| 炉霍县| 元江| 桓台县| 公安县| 玉树县| 遂川县| 都兰县| 当涂县| 瓮安县| 吴桥县| 平原县| 丹寨县| 新营市| 锡林浩特市| 宁晋县| 牡丹江市| 梅河口市| 郯城县| 古丈县| 自贡市| 德昌县| 福贡县| 个旧市| 玉山县| 太仆寺旗| 手游| 云阳县| 长宁区|