FAQ(43): com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL sy
2018/1/3
spring对Mybatis整合,
看Log:
org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.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 'b.providerId='1',b.isPayment='2'and b.providerId=p.id' at line 3
### The error may exist in com/smbms/dao/BillMapper.xml
### The error may involve com.smbms.dao.BillMapper.billShowByCondition-Inline
### The error occurred while setting parameters
### SQL: select b.billCode,b.productName,p.proName,b.totalPrice,b.isPayment,b.creationDate from smbms_bill b,smbms_provider p where b.productName=?,b.providerId=?,b.isPayment=? and b.providerId=p.id
### Cause: com.mysql.jdbc.exceptions.jdbc4.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 'b.providerId='1',b.isPayment='2'and b.providerId=p.id' at line 3
; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.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 'b.providerId='1',b.isPayment='2'and b.providerId=p.id' at line 3at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)at com.sun.proxy.$Proxy8.selectList(Unknown Source)at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:137)at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:75)at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)at com.sun.proxy.$Proxy11.billShowByCondition(Unknown Source)at com.smbms.service.BillServiceImpl.findBillsWithConditionsByThressConditions(BillServiceImpl.java:19)at com.smbms.service.BillServiceImplTest.test(BillServiceImplTest.java:30)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)at org.junit.runners.ParentRunner.run(ParentRunner.java:363)at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.mysql.jdbc.exceptions.jdbc4.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 'b.providerId='1',b.isPayment='2'and b.providerId=p.id' at line 3at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)at java.lang.reflect.Constructor.newInstance(Unknown Source)at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)at com.mysql.jdbc.Util.getInstance(Util.java:408)at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:943)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2527)at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2680)at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2487)at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1197)at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)at com.sun.proxy.$Proxy13.execute(Unknown Source)at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79)at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63)at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324)at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156)at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109)at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148)at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)at java.lang.reflect.Method.invoke(Unknown Source)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)... 31 more
解决:sql 语句修改,参数和列名有误!
b.productName=#{produceName}
改为 b.produceName=#{produceName}
FAQ(43): com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL sy相关推荐
- mybatis-plus调用自身的 selectById 方法报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You hav
1.报错信息: 1.1早上的报错信息:这个是我下午模拟上午的错误(已经通过1.2里面的错误信息找到错误原因了),让他产生错误信息,但是这个和上午产生的错误信息不一样了,上午的我不知道错误在哪,这个就知 ...
- 解决com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
解决com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 1. 报错内容 com.mysql.jdbc.exceptions.jdbc4 ...
- 已解决idea连接数据库异常:Exception in thread “main“ com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GR
项目场景: sql报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'rtjhyt' in 'field list'
今天向数据库中插入语句遇到了这样的异常: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'rtjh ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'test'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database 'test' com.mysql.jdbc.ex ...
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 't.statis_date'
1.错误原因 [ERROR:]2015-04-18 13:20:31,883 [异常拦截] com.skycloud.oa.exception.ExceptionHandler org.hiberna ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:异常问题解析!
首先遇到这样的问题,肯定是你的sql写错了,应该不用怀疑,虽然我把sql代码抽取出来在sql 单独运行了一遍,没有报错,但是还是sql语法的错误,下面先上错误的代码 <select id=&qu ...
- com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: FUNCTION security.to_date does not exist
Mybatis中的这样写条件时,运行报错 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: FUNCTION security.to ...
最新文章
- 财务人员学python有用吗-一个来自35岁职场高管的忠告:Python为什么不得不学?...
- 概率编程库Pymc3案例之神经网络(批量训练)
- shell脚本读取csv_shell script 处理 CSV 文件(Excel)
- 线性代数导论4——A的LU分解
- windows安装python3步骤_Windows下python3和python2安装与一起使用
- 大数据项目实战数仓4——常用脚本
- [No0000143]Win10“卓越性能模式”
- k2-fsa differentiable Finite State Acceptor(Dan 的 toturial总结)
- 计算机基础的课程标准,《计算机基础》课程标准
- 今天看完了《勇敢的心》非常感动,收集了些资料!希望大家喜欢。
- 观影《铁拳男人》有感
- 021淘宝轮播图制作
- HTML中表格和表单的简单构造和样式
- Hu距(Hu Moments)图像距介绍
- 儿童玩具和儿童用品美国CPC认证ASTM测试CPSIA标准大合集
- 宜家东京出租房,每月租金1美金
- Android开发定位
- #pragma加载lib文件
- 基于ALIENTEK MINISTM32开发板 ADC+DMA 8通道显示
- fatal: unsafe repository Git权限问题修复