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 想飛的魚 閱讀(2428) 評論(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
            回復  更多評論
            
          主站蜘蛛池模板: 临武县| 安丘市| 平度市| 郯城县| 新泰市| 门头沟区| 孟津县| 百色市| 汕头市| 昌都县| 昭通市| 鲁甸县| 眉山市| 连州市| 金堂县| 洪湖市| 盱眙县| 鲜城| 岳普湖县| 长海县| 双桥区| 苏州市| 黔西| 沈丘县| 台安县| 炎陵县| 洛浦县| 苍山县| 台北县| 永嘉县| 柳江县| 庆城县| 牡丹江市| 内江市| 孟村| 文化| 新晃| 台安县| 克拉玛依市| 梓潼县| 揭阳市|