当我尝试将以下数据保存到数据库时出现错误。
• 太阳能电池性能的独立测量和校准 在太空和*独一无二的*条件下(即高强度/ 温度、单色和室内照明条件等) • 新型能源转换装置,例如远程自供电装置 传感器;宽带、单色或热能源; 集成通信/电源概念等
我收到错误,因为一些不需要的文本(在上面的文本中标记为粗体和斜体)我们无法插入到数据库中。数据库表排序规则为“utf8_general_ci”,字符集为“utf”
Error ::
*03:20:20,775 WARN [org.hibernate.util.JDBCExceptionReporter] SQL Error: 1366, SQLState: HY000
03:20:20,775 ERROR [org.hibernate.util.JDBCExceptionReporter] Incorrect string value: '\xF4\x80\x81\xACun...' for column 'VALUE' at row 1
03:20:20,784 ERROR [com.platform.ejb.OpportunityServicesBean] could not insert: [com.platform.valueobject.OpportunityExtension]: org.hibernate.exception.GenericJDBCException: could not insert: [com.platform.valueobject.OpportunityExtension]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140) [:3.6.6.Final]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128) [:3.6.6.Final]
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) [:3.6.6.Final]
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:64) [:3.6.6.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2345) [:3.6.6.Final]*
如果我删除不需要的文本,那么数据就会保存到数据库中。
谁能帮我出来吗?
最佳答案
你可以在MySQL中将其定义为VARCHAR(N),但是你
应指定一些正确的字符集和排序规则。
http://dev.mysql.com/doc/refman/5.1/en/string-type-overview.html
http://dev.mysql.com/doc/refman/5.1/en/charset-column.html
关于java - Unicode 数据不保存到 MySQL 数据库中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20654645/