hibernate+mysql存中文问题

hibernate+mysql存中文问题
环境: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)

你可能感兴趣的:(hibernate+mysql存中文问题)