欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mysql数据库执行insert时的编码问题

程序员文章站 2022-06-01 17:06:04
...
--- The error occurred in sqlmap/shared/EgSiteLog-sqlmap-mapping.xml.  
--- The error occurred while applying a parameter map.  
--- Check the ecmng.EgSiteLog.insert-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLException: Incorrect string value: '\xD0\xDE\xB8\xC4\xC4\xDA...' for column 'sysaction' at row 1
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:107)
	at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.insert(SqlMapExecutorDelegate.java:393)
	at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.insert(SqlMapSessionImpl.java:82)
	at org.springframework.orm.ibatis.SqlMapClientTemplate$9.doInSqlMapClient(SqlMapClientTemplate.java:399)
	at org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:209)
	... 85 more
Caused by: java.sql.SQLException: Incorrect string value: '\xD0\xDE\xB8\xC4\xC4\xDA...' for column 'sysaction' at row 1
	at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
	at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
	at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
	at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
	at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2626)
	at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2111)
	at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:168)
	at net.sf.log4jdbc.PreparedStatementSpy.execute(PreparedStatementSpy.java:413)
	at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeUpdate(SqlExecutor.java:80)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteUpdate(MappedStatement.java:216)
	at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeUpdate(MappedStatement.java:94)
	... 89 more

 刚刚碰到这个问题,是跟编码相关,在创建表的时候,会让你选择一种编码方式,我没有选择,就是用默认的(我的默认编码方式是latin1),解决的办法是将这个字段的编码方式改成gbk(注意:这个时候如果再去修改表的编码方式,对字段的编码方式貌似是没有影响的)