hibernate struts2 spring整合的框架无法插入中文,报错如下

数据库连接的properties文件已加上useUnicode=true&characterEncoding=utf8
数据库表也已设置为utf-8


  1. Struts Problem Report

  2. Struts has detected an unhandled exception:

  3. Messages:
    1. Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'pname' at row 1

    2. Hibernate operation: could not insert: [com.umbrella.ssh.domain.Product]; uncategorized SQLException for SQL [insert into product (pname, price) values (?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'pname' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'pname' at row 1

    File:com/mysql/jdbc/SQLError.java
    Line number:1,056
  4. Stacktraces

  5. org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.umbrella.ssh.domain.Product]; uncategorized SQLException for SQL [insert into product (pname, price) values (?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'pname' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xE4\xB8\xAD\xE6\x96\x87' for column 'pname' at row 1

  6.     org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
        org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
        org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:410)
        org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:412)
        org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:375)
        org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:684)
        com.umbrella.ssh.dao.ProductDao.save(ProductDao.java:11)
        com.umbrella.ssh.service.ProductService.save(ProductService.java:20)
        com.umbrella.ssh.service.ProductService$$FastClassBySpringCGLIB$$f8c996e2.invoke(<generated>)
fenkapian
浏览 2424回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java