wiflish
          Loving Life! Loving Coding!
          posts - 98,comments - 98,trackbacks - 0
          環境:hibernate3.1 + mysql4.1 + mysql-connector-java-3.0.11-stable-bin.jar驅動
          當將mysql的默認字符集設置成default-character-set=gbk,插入中文字符時出現
          例子:
          Hibernate: insert into book (bookpagenum, published, bookname, bookauthor) values (?, ?, ?, ?)
          could not bind value '待插入的中文字符' to parameter: 2; String index out of range: 9

          這是mysql的mysql-connector-java-3.0.11-stable-bin.jar驅動問題。更換驅動就好了
          (比如:mysql-connector-java-3.1.13-bin.jar)

          posted on 2006-06-30 11:47 想飛的魚 閱讀(2418) 評論(2)  編輯  收藏 所屬分類: hibernate

          FeedBack:
          # could not bind value '6' to parameter: 3
          2006-11-23 09:24 | could not bind value '6' to parameter: 3
          數據庫調用
          String[] params = {"identifier","fileType","topNum"};
          Object[] values = {1,1,10};
          String selectQuery = FROM File hq WHERE hq.createParty.identifier=:identifier AND fileType = :fileType AND rownum < :topNum ORDER BY hq.createTime DESC;
          //this.getFileDao().getObjects 這個方法就是調用Hibernate的方法,沒有對參數進行任何的操作
          return this.getFileDao().getObjects(selectQuery, params, values);

          異常:
          2006-11-23 9:15:54 org.hibernate.type.NullableType nullSafeSet
          信息: could not bind value '6' to parameter: 3
          2006-11-23 9:15:54 org.hibernate.util.JDBCExceptionReporter logExceptions
          警告: SQL Error: 17041, SQLState: null
          2006-11-23 9:15:54 org.hibernate.util.JDBCExceptionReporter logExceptions
          嚴重: 索引中丟失 IN 或 OUT 參數:: 3


            回復  更多評論
            
          # re: hibernate+mysql存中文問題
          2006-11-23 09:25 | could not bind value '6' to parameter: 3
          String[] params = {"identifier","fileType","topNum"};
          Object[] values = {1,1,6};
          String selectQuery = FROM File hq WHERE hq.createParty.identifier=:identifier AND fileType = :fileType AND rownum < :topNum ORDER BY hq.createTime DESC;
          //this.getFileDao().getObjects 這個方法就是調用Hibernate的方法,沒有對參數進行任何的操作
          return this.getFileDao().getObjects(selectQuery, params, values);

          異常:
          2006-11-23 9:15:54 org.hibernate.type.NullableType nullSafeSet
          信息: could not bind value '6' to parameter: 3
          2006-11-23 9:15:54 org.hibernate.util.JDBCExceptionReporter logExceptions
          警告: SQL Error: 17041, SQLState: null
          2006-11-23 9:15:54 org.hibernate.util.JDBCExceptionReporter logExceptions
          嚴重: 索引中丟失 IN 或 OUT 參數:: 3
            回復  更多評論
            
          主站蜘蛛池模板: 华亭县| 南溪县| 塔城市| 铜陵市| 彭水| 安仁县| 册亨县| 浠水县| 靖远县| 孝义市| 绥芬河市| 桦南县| 徐州市| 沙河市| 尼木县| 犍为县| 柳江县| 寻乌县| 阿拉善盟| 深水埗区| 临桂县| 福海县| 南靖县| 忻州市| 古蔺县| 顺义区| 罗山县| 晋州市| 南城县| 微山县| 和静县| 萝北县| 凤翔县| 介休市| 泗水县| 拜泉县| 阿拉善盟| 伊吾县| 西盟| 顺平县| 图木舒克市|