Mysql插入数据的问题
发表在JavaWeb图书答疑 2015-03-24
是否精华
版块置顶:
老师,我现在正在做的是《实战突击:Java Web项目整合开发》这本书的第十章网上选课系统,我已经把项目工程重新导入了一遍,所有的jar包也复制进去了,但还是在插入数据时出问题,它可以读出数据库,插入的是数字和字母也可以,但插入中文字符时报下面的错误,请老师看一下,说一下解决方法,如果缺少什么文件,能不能直接发我一份


HTTP Status 500 - org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.jwy.dto.Specialty]; uncategorized SQLException for SQL [insert into db_database10.tb_specialty (enterYear, name, langthYear, isFinish) values (?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1

type Exception report

message org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.jwy.dto.Specialty]; uncategorized SQLException for SQL [insert into db_database10.tb_specialty (enterYear, name, langthYear, isFinish) values (?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.jwy.dto.Specialty]; uncategorized SQLException for SQL [insert into db_database10.tb_specialty (enterYear, name, langthYear, isFinish) values (?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:535)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:433)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause

org.springframework.jdbc.UncategorizedSQLException: Hibernate operation: could not insert: [com.jwy.dto.Specialty]; uncategorized SQLException for SQL [insert into db_database10.tb_specialty (enterYear, name, langthYear, isFinish) values (?, ?, ?, ?)]; SQL state [HY000]; error code [1366]; Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1; nested exception is java.sql.SQLException: Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1
org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
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:424)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
com.jwy.dao.SpecialtyDao.insert(SpecialtyDao.java:44)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy6.insert(Unknown Source)
com.jwy.action.SpecialtyAction.insert(SpecialtyAction.java:36)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
root cause

java.sql.SQLException: Incorrect string value: '\xC2\xBE\xC3\x8D\xC2\xB0...' for column 'name' at row 1
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2019)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937)
com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922)
org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.executeAndExtract(IdentityGenerator.java:94)
org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2186)
org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2666)
org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71)
org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:321)
org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:562)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:550)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:546)
org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:697)
org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:694)
com.jwy.dao.SpecialtyDao.insert(SpecialtyDao.java:44)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
$Proxy6.insert(Unknown Source)
com.jwy.action.SpecialtyAction.insert(SpecialtyAction.java:36)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.39 logs.
分享到:
精彩评论 1
学分: LV1
TA的每日心情
开心
2021-10-26 19:13:33
2015-04-08
沙发
改下数据库中表的编码格式:ALTER TABLE  表名  DEFAULT CHARACTER SET 现在的编码方式(gb2312) COLLATE 新的编码方式(utf8_general_ci)。试试这个命令,然后插入中文的数据看看能否成功插入
首页上一页 1 下一页尾页 1 条记录 1/1页
手机同步功能介绍
友情提示:以下图书配套资源能够实现手机同步功能
明日微信公众号
明日之星 明日之星编程特训营
客服热线(每日9:00-17:00)
400 675 1066
mingrisoft@mingrisoft.com
吉林省明日科技有限公司Copyright ©2007-2022,mingrisoft.com, All Rights Reserved长春市北湖科技开发区盛北大街3333号长春北湖科技园项目一期A10号楼四、五层
吉ICP备10002740号-2吉公网安备22010202000132经营性网站备案信息 营业执照