Mybatis新增出现异常 是不是jsp乱码问题题

感谢评语:
本页链接:
匿名网友Caused by: com.mysql.jdbc.exceptions.jdb**.MySQLSyntaxErrorException: Unknown column '°èè‰' in 'field list'主要看这句,的确是 乱码问题
最新解决问题列表
猜你感兴趣Mybatis新增出现异常
是不是乱码问题 - 网志问答
AD760-90当前位置: & Mybatis新增出现异常
是不是乱码问题已解决问题Mybatis新增出现异常
是不是乱码问题 org.apache.ibatis.exceptions.PersistenceException:&### Error updating database. &Cause: com.mysql.jdbc.exceptions.jdb**.MySQLSyntaxErrorException: Unknown column '°èè‰' in 'field list'### The error may involve defaultParameterMap### The error occurred while setting parameters### SQL: IN**RT INTO employee(NAME,PASSWORD,d_id) & VALUE(小试身手,222,2)### Cause: com.mysql.jdbc.exceptions.jdb**.MySQLSyntaxErrorException: Unknown column '°èè‰' in 'field list'at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.j**a:30)at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.j**a:200)at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.j**a:185)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.j**a:57)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.j**a:53)at com.sun.proxy.$Proxy4.insertEmp(Unknown Source)at mvc.test.empTest.test01(empTest.j**a:45)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j**a:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.j**a:43)at j**a.lang.reflect.Method.invoke(Method.j**a:606)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.j**a:47)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.j**a:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.j**a:44)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.j**a:17)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.j**a:271)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.j**a:70)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.j**a:50)at org.junit.runners.ParentRunner$3.run(ParentRunner.j**a:238)at org.junit.runners.ParentRunner$1.sche**le(ParentRunner.j**a:63)at org.junit.runners.ParentRunner.runChildren(ParentRunner.j**a:236)at org.junit.runners.ParentRunner.access$000(ParentRunner.j**a:53)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.j**a:229)at org.junit.runners.ParentRunner.run(ParentRunner.j**a:309)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.j**a:50)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.j**a:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.j**a:467)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.j**a:683)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.j**a:390)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.j**a:197)Caused by: com.mysql.jdbc.exceptions.jdb**.MySQLSyntaxErrorException: Unknown column '°èè‰' in 'field list'at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.j**a:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.j**a:45)at j**a.lang.reflect.Constructor.newInstance(Constructor.j**a:526)at com.mysql.jdbc.Util.handleNewInstance(Util.j**a:353)at com.mysql.jdbc.Util.getInstance(Util.j**a:336)at com.mysql.jdbc.SQLError.createSQLException(SQLError.j**a:1031)at com.mysql.jdbc.SQLError.createSQLException(SQLError.j**a:957)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.j**a:2938)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.j**a:1601)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.j**a:1710)at com.mysql.jdbc.Connection.execSQL(Connection.j**a:2436)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.j**a:1402)at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.j**a:977)at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.j**a:46)at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.j**a:74)at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.j**a:50)at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.j**a:117)at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.j**a:76)at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.j**a:198)... 28 more
详细问题描述及疑问:期待您的答案,谢谢你帮我,祝你快乐,愿你事事如意

本页链接:ADADAD
满意答案Caused by: com.mysql.jdbc.exceptions.jdb**.MySQLSyntaxErrorException: Unknown column '°èè‰' in 'field list'主要看这句,的确是 乱码问题
AD728-90相关内容AD
大家还关注AD160-600mybatis mapper文件有中文插入oracle数据库是乱码 问题
[问题点数:30分,结帖人kanlianhui]
mybatis mapper文件有中文插入oracle数据库是乱码 问题
[问题点数:30分,结帖人kanlianhui]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
匿名用户不能发表回复!|解决springmvc+mybatis+mysql中文乱码问题【转】
我的图书馆
解决springmvc+mybatis+mysql中文乱码问题【转】
这篇文章主要介绍了解决java中springmvc+mybatis+mysql中文乱码问题的相关资料,需要的朋友可以参考下近日使用ajax请求springmvc后台查询mysql数据库,页面显示中文出现乱码最初在mybatis配置如下&select id="queryContentById" resultType = "java.lang.String" parameterType="String" &&&&&select text from News where id=#{o} &/select&其中表News的text字段为blob类型如此查出的text值在控制台中一直显示乱码。之后google查找相关resultType=blob相关内容无果,遂将其改为resultType = "java.util.Map" ,且12byte[] b = (byte[]) map.get("text");String s = new String(b,"utf-8");打印出s,此时中文正常显示,但页面显示依旧乱码。因此处为ajax请求,遂检查响应头信息,查出如下1Content-Typetext/charset=ISO-8859-1由于数据库中统一为编码为utf-8,故修改响应头信息@RequestMapping(value = "/queryContentById", method = RequestMethod.GET,produces = "text/charset=UTF-8")public @ResponseBody String queryContentById(@RequestParam("id") String id) throws SQLException, UnsupportedEncodingException {&&Map map = (Map) ndrService.queryContentById(id);&&byte[] b = (byte[]) map.get("text");&&String s = new String(b,"utf-8");&&return s;}我们再来看下另外一个示例的问题1、SpringMVC的Controller得到的是乱码:(1)在web.xml加上字符集过滤器:代码如下:&&!-- Spring字符集过滤器 --&&&filter&&&&filter-name&SpringEncodingFilter&/filter-name&&&&filter-class&org.springframework.web.filter.CharacterEncodingFilter&/filter-class&&&&init-param&&&&&param-name&encoding&/param-name&&&&&param-value&UTF-8&/param-value&&&&/init-param&&&&init-param&&&&&param-name&forceEncoding&/param-name&&&&&param-value&true&/param-value&&&&/init-param&&&/filter&&&filter-mapping&&&&filter-name&SpringEncodingFilter&/filter-name&&&&url-pattern&/*&/url-pattern&&&/filter-mapping&(2)在JSP等页面上修改:charset=UTF-8"和pageEncoding="UTF-8"2、Controller读取到的是正确的中文,但是保存到数据库后变成“??”(1)修改数据库连接jdbc_url=jdbc:mysql://localhost:3306/mybatistest?useUnicode=yes&characterEncoding=UTF8("&":在xml文件中表示"&")(2)修改数据库的字符集为utf-8:打开mysql根目录下my.ini(mysql5.6为my-default.ini,要把它copy一份命名为my.ini),在下面具体位置添加(或修改):代码如下:[mysqld]character-set-server=utf8 [client]default-character-set = utf8[mysql]default-character-set = utf8这样设置在我这边就没什么问题了。综述:通常中文乱码问题都是由于字符编码设置不对导致的,我这里无论是数据库还是java文件、jsp文件,都统一成UTF-8。最后问题解决了。
TA的最新馆藏
喜欢该文的人也喜欢今天有个同事将mysql库迁移后回滚测试发现插入数据乱码。
由于代码基本上改动,可以断定是数据库的迁移引起来的问题,于是我就在mybatis里面直接执行sql的地方加上断点,发现要执行的sql就已经乱码。
然后我就怀疑是否是入参数的时候是乱码,经过发现在设置参数的时候object的值均正常。
也就是SimpleExcutor的doUpdate函数:
后来经过查看数据的编码,发现两个数据库的编码格式不相同,
参考编码的sql如下:
show variables like '%character%';
后来发现它的连接字符串如下:
xxxx.jdbc.url=jdbc:mysql://192.168.14.203:3306/xxxx?useUnicode=true&characterEncoding=UTF-8
后来经过测试:
原因是properties里面不能将&转译
下面的写法就可以:
xxxx.jdbc.url=jdbc:mysql://192.168.14.203:3306/xxxx?useUnicode=true&characterEncoding=UTF-8
但是如果在xml里面的话,要转译
xxxx.jdbc.url=jdbc:mysql://192.168.14.203:3306/xxxx?useUnicode=true&characterEncoding=UTF-8
但是有一个问题,为什么同样的代码在一个数据库上可以,换一个就不行了呢? 原因是第一个数据库所以的编码默认都是utf8,所以参数写错了也不会有影响,而第二个数据库编码格式有问题的时候,参数就要起效果了,不对的时候就会引起问题。 所以还是希望大家在安装数据库的时候,将默认编码设置成utf8.
浏览: 925505 次
来自: 北京
ddnzero 写道博主请问FileUtils这个类是哪个包的 ...
博主请问FileUtils这个类是哪个包的?还是自己的呢?能放 ...
为什么会intMap.get(&bbb&) ...
感觉LogManager打开了所有的LogSegment(文件 ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'

我要回帖

更多关于 post请求中文乱码问题 的文章

 

随机推荐