mybatis自己生成的xml文件为啥还会报语句错误啊!急急急!~!!!!

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis自己生成的xml文件为啥还会报语句错误啊!急急急!~!!!!相关的知识,希望对你有一定的参考价值。

org.springframework.jdbc.BadSqlGrammarException: ### Error updating database. Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't where t.roleid = 'b28ff4a6-b321-11e3-b8bf-ae07594e7314'' at line 1 ### The error may involve com.pioneer.yuelian.mapper.SysRoleMenuMapper.deleteByPrimaryKey-Inline ### The error occurred while setting parameters ### SQL: delete from t_sys_rolemenu t where t.roleid = ? ### Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't where t.roleid = 'b28ff4a6-b321-11e3-b8bf-ae07594e7314'' at line 1 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't where t.roleid = 'b28ff4a6-b321-11e3-b8bf-ae07594e7314'' at line 1

参考技术A where
t.roleid
=
'b28ff4a6-b321-11e3-b8bf-ae07594e7314''
这一句旁边看看是不是语句错误,有没有多加了个
单引号

Mybatis中Mapper.xml文件中注释存在中文报错问题

在Mapper.xml中注释中文时,编译会报如下错误

Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:702)
	at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(UTF8Reader.java:373)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(XMLEntityScanner.java:1895)
	at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.scanData(XMLEntityScanner.java:1389)
	at com.sun.org.apache.xerces.internal.impl.XMLScanner.scanComment(XMLScanner.java:801)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanComment(XMLDocumentFragmentScannerImpl.java:1036)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2984)
	... 16 more

将xml的文件头encoding="UTF-8"改为encoding="UTF8"后问题解决

以上是关于mybatis自己生成的xml文件为啥还会报语句错误啊!急急急!~!!!!的主要内容,如果未能解决你的问题,请参考以下文章

在shell脚本执行sql语句为啥会报错

为啥创建maven项目会报错

mybatis中xml映射和方法注解两种配置sql语句的方式是不是可以同时存在

Mybatis中Mapper.xml文件中注释存在中文报错问题

mybatis,Spring等工具对xml文件正确性的验证

Mybatis反向生成