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 想飞的鱼 阅读(2408) 评论(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
  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: