`

mysql插入中文

阅读更多
 Struts has detected an unhandled exception:
Messages: 	

   1. Incorrect string value: '\xA1\xAA\xA1\xAA\xB0\xFC...' for column 'content' at row 1
   2. Hibernate flushing: Could not execute JDBC batch update; uncategorized SQLException for SQL [insert into blog (comments, content, createdate, description, tid, title, uid, id) values (?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xA1\xAA\xA1\xAA\xB0\xFC...' for column 'content' at row 1; nested exception is java.sql.BatchUpdateException: Incorrect string value: '\xA1\xAA\xA1\xAA\xB0\xFC...' for column 'content' at row 1

File: 	com/mysql/jdbc/ServerPreparedStatement.java
Line number: 	657


最近在发表文章的时候 却出现了这样的错误。

不知道什么原因 ,在有时插入的时候不会出错  但有时又出错。。

后来发现  原来是mysql的表中字段为gb2312_chinese_ci  而程序中使用的utf-8  这可能是乱码所致。

参考:http://www.java1995.cn/blog/item/17
0
0
分享到:
评论
1 楼 wangking717 2011-11-11  
我程序上以及数据库上都是用的UTF8,都出现了这样的问题,所以LZ还是没找到解决的原因。。

相关推荐

Global site tag (gtag.js) - Google Analytics