<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 11,  comments - 28,  trackbacks - 0
    今天在繼續研究JShopStore時候,在查看product的明細時即
    執行action
    ????<action?path="/shop/viewItem"?type="org.apache.struts.beanaction.BeanAction"
    ????????????name
    ="catalogBean"?scope="session"
    ????????????validate
    ="false"?input="/catalog/Product.jsp">
    ??????
    <forward?name="success"?path="/catalog/Item.jsp"/>
    ????
    </action>
    報NestedSqlException錯誤,錯誤的核心部分如下:
    Caused?by:?com.ibatis.dao.client.DaoException:?Failed?to?execute?queryForObject?-?id?[getItem],?parameterObject?[EST-18].??Cause:?com.ibatis.common.jdbc.exception.NestedSQLException:???
    ---?The?error?occurred?in?com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml.??
    ---?The?error?occurred?while?applying?a?parameter?map.??
    ---?Check?the?getItem-InlineParameterMap.??
    ---?Check?the?statement?(query?failed).??
    ---?Cause:?java.sql.SQLException:?[Microsoft][SQLServer?2000?Driver?for?JDBC][SQLServer]???'itemid'?????
    Caused?by:?java.sql.SQLException:?[Microsoft][SQLServer?
    2000?Driver?for?JDBC][SQLServer]???'itemid'?????
    Caused?by:?com.ibatis.common.jdbc.exception.NestedSQLException:???
    ---?The?error?occurred?in?com/ibatis/jpetstore/persistence/sqlmapdao/sql/Item.xml.??
    ---?The?error?occurred?while?applying?a?parameter?map.??
    ---?Check?the?getItem-InlineParameterMap.??
    ---?Check?the?statement?(query?failed).??
    ---?Cause:?java.sql.SQLException:?[Microsoft][SQLServer?2000?Driver?for?JDBC][SQLServer]???'itemid'?????
    我跟蹤、跟蹤,跟蹤到ItemSqlMapDao
    ??public?Item?getItem(String?itemId)?{
    ????Integer?i?
    =?(Integer)?queryForObject("getInventoryQuantity",?itemId);
    ????Item?item?
    =?(Item)?queryForObject("getItem",?itemId);
    ????item.setQuantity(i.intValue());
    ????
    return?item;
    ??}
    找到錯誤語句
    Item item = (Item) queryForObject("getItem", itemId);
    繼續跟蹤到操縱的sql_map文件Item.xml
    <select?id="getItem"?resultClass="item"?parameterClass="string"?cacheModel="quantityCache">
    ????select
    ??????ITEMID,
    ??????LISTPRICE,
    ??????UNITCOST,
    ??????SUPPLIER?AS?supplierId,
    ??????I.PRODUCTID?AS?"product.productId",
    ??????NAME?AS?"product.name",
    ??????DESCN?AS?"product.description",
    ??????CATEGORY?AS?"product.categoryId",
    ??????STATUS,
    ??????ATTR1?AS?attribute1,
    ??????ATTR2?AS?attribute2,
    ??????ATTR3?AS?attribute3,
    ??????ATTR4?AS?attribute4,
    ??????ATTR5?AS?attribute5,
    ??????QTY?AS?quantity
    ????from?ITEM?I,?INVENTORY?V,?PRODUCT?P
    ????where?P.PRODUCTID?=?I.PRODUCTID
    ??????and?I.ITEMID?=?V.ITEMID
    ??????and?I.ITEMID?=?#value#
    ??
    </select>
    問題就出現在這,Item類中包含了Product類,出現NestedSqlException錯誤。
    查閱了ibatis幫助,此處sql_map的嵌套類寫法是正確的。我又將這個sql語句拷貝到MsSqlServer中執行,結果也是正確的。陷入困惑。
    在網上找資料,發現了一個英文網站中指明了
    ---?Cause:?java.sql.SQLException:?[DataDirect][SQLServer?JDBC?Driver][SQLServer]Ambiguous?column?name?'itemid'.?
    哈哈,問題就此找到了。即itemid列指待不清,應該將ITEMID替換成I.ITEMID AS ITEMID。而之所以我直接將語句拷貝到MsSqlServer執行正確,是因為MSSqlServer自動做了處理,加上了表的別名。而這個Sql語句本身是存在問題的。
    所以item.xml替換后的代碼為
    ??<select?id="getItem"?resultClass="item"?parameterClass="string"?cacheModel="quantityCache">
    ????select
    ??????I.ITEMID?AS?ITEMID,
    ??????LISTPRICE,
    ??????UNITCOST,
    ??????SUPPLIER?AS?supplierId,
    ??????I.PRODUCTID?AS?"product.productId",
    ??????NAME?AS?"product.name",
    ??????DESCN?AS?"product.description",
    ??????CATEGORY?AS?"product.categoryId",
    ??????STATUS,
    ??????ATTR1?AS?attribute1,
    ??????ATTR2?AS?attribute2,
    ??????ATTR3?AS?attribute3,
    ??????ATTR4?AS?attribute4,
    ??????ATTR5?AS?attribute5,
    ??????QTY?AS?quantity
    ????from?ITEM?I,?INVENTORY?V,?PRODUCT?P
    ????where?P.PRODUCTID?=?I.PRODUCTID
    ??????and?I.ITEMID?=?V.ITEMID
    ??????and?I.ITEMID?=?#value#
    ??
    </select>
    問題解決,OK!誒,亂碼也耽誤了一些時間,否則早就解決了,看來亂碼誤事啊!
    posted on 2007-01-16 13:38 滌生 閱讀(3365) 評論(6)  編輯  收藏


    FeedBack:
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤[未登錄]
    2007-01-16 17:06 | junmy
    posted on 2006-05-22 00:42
    http://m.tkk7.com/wujun/archive/2006/05/22/47392.html
    早就發現了~
      回復  更多評論
      
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤
    2007-01-16 20:21 | 滌生
    @junmy
    今天我還在blogjava上找了一圈,沒找到對應的。要是早看到你的大作,可以省我半個上午的時間  回復  更多評論
      
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤[未登錄]
    2007-01-18 19:44 | BeanSoft
    強烈建議 dudu 加入全文索引... 沒搜索這么多 blog 也是很浪費啊...  回復  更多評論
      
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤
    2008-10-20 20:40 | Guest
    我也是這樣改的,不過仍然還是錯誤。。。搞不明白呢。  回復  更多評論
      
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤
    2010-02-06 13:09 | ossoftwaare
    好內容,以前研究過,不過好久了, 最近寫了幾句,也發現了這個問題  回復  更多評論
      
    # re: ibatis JshopStore5的sqlmap的xml錯誤,NestedSQLException錯誤
    2010-12-10 14:48 | LingShame
    @junmy
    你走得路,先人已經走過N多次了.
    你再走來,不覺得可恥嗎?  回復  更多評論
      

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    <2007年1月>
    31123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    常用鏈接

    留言簿(5)

    隨筆檔案

    UML

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 在线观看亚洲网站| 亚洲精品美女在线观看播放| 亚洲av无码成人影院一区| 99久久99这里只有免费费精品| 亚洲高清视频免费| 2021国内精品久久久久精免费| 亚洲国产日韩在线成人蜜芽| 国产成人精品久久免费动漫| 亚洲第一男人天堂| 香蕉视频在线观看免费国产婷婷| 亚洲hairy多毛pics大全| 免费h成人黄漫画嘿咻破解版| 美女被羞羞网站免费下载| 亚洲中文字幕无码专区| 国产精品高清免费网站| 亚洲另类激情综合偷自拍图| 久久久久久夜精品精品免费啦| 亚洲成AV人片久久| 免费看又爽又黄禁片视频1000| 美女啪啪网站又黄又免费| 久久精品亚洲男人的天堂| 久久久久国产免费| 97se亚洲国产综合自在线| 国产网站在线免费观看| 99热在线日韩精品免费| 亚洲中文久久精品无码1| 国产成人免费a在线视频app| 99在线免费观看| 亚洲一级视频在线观看| yy6080久久亚洲精品| 久久国产乱子伦精品免费强| 国产精品亚洲综合五月天| 亚洲人成影院在线无码观看| 亚洲w码欧洲s码免费| 免费观看又污又黄在线观看| 91在线精品亚洲一区二区| 国产免费爽爽视频免费可以看| 免费黄网站在线观看| 风间由美在线亚洲一区| 亚洲毛片在线观看| 免费一级毛片不卡在线播放|