盡人事而順天命

          關注 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 閱讀(646) | 評論 (1)編輯 收藏

          主站蜘蛛池模板: 德清县| 浦东新区| 淮安市| 喀喇沁旗| 兴隆县| 房山区| 南安市| 武乡县| 怀宁县| 普安县| 武胜县| 固原市| 涿鹿县| 迭部县| 红河县| 安陆市| 安吉县| 麻阳| 黎平县| 湘潭市| 开原市| 科尔| 彩票| 通城县| 固始县| 大港区| 衡南县| 阿克苏市| 武汉市| 民乐县| 鹤壁市| 龙里县| 秀山| 泰宁县| 安陆市| 石首市| 天等县| 青铜峡市| 乌兰县| 佳木斯市| 安丘市|