低级sql语法错误:BadSqlGrammarException
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:760)
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
at com.lk.ActivemqApplication.main(ActivemqApplication.java:12)
Caused by: org.springframework.jdbc.BadSqlGrammarException:
### Error querying database. Cause: ptions.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 'AS SELECT queue_message_entity WHERE `insert_time` <
'1970-01-01 08:00:55'' at line 1
### The error may exist in com/lk/loms/mq/service/dao/mapper/HistoryMsgMapper.java (best guess)
springboot aop### The error may involve com.lk.loms.mq.service.dao.mapper.HistoryMsgMapper.insertQueueBackup-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO queue_message_entity_bak AS SELECT queue_message_entity WHERE `insert_time` < ?
### Cause: ptions.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 'AS SELECT queue_message_entity WHERE `insert_time` < '1970-01-01 08:00:55'' at line 1
; bad SQL grammar []; nested exception ptions.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 'AS SELECT queue_message_entity WHERE `insert_time` < '1970-01-01 08:00:55'' at line 1
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.anslate(AbstractFallbackSQLExceptionTranslator.java:73)
batis.anslateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
batis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
at com.sun.proxy.$Proxy120.selectOne(Unknown Source)
batis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:166)
at org.apache.ibatis.ute(MapperMethod.java:83)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy121.insertQueueBackup(Unknown Source)
flect.NativeMethodAccessorImpl.invoke0(Native Method)
flect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
flect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at flect.Method.invoke(Method.java:498)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
at com.sun.proxy.$Proxy123.insertQueueBackup(Unknown Source)
at com.lk.BackupCommandLineRunner.insertQueueBackup(BackupCommandLineRunner.java:61)
at com.lk.BackupCommandLineRunner.run(BackupCommandLineRunner.java:27)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:776)
... 6 common frames omitted
Caused by: ptions.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 'AS SELECT queue_message_entity WHERE `insert_time` < '1970-01-01 08:00:55'' at line 1
wInstance0(Native Method)
wInstance(NativeConstructorAccessorImpl.java:62)
wInstance(DelegatingConstructorAccessorImpl.java:45)
at wInstance(Constructor.java:423)
sql.jdbc.Util.handleNewInstance(Util.java:425)
sql.Instance(Util.java:408)
sql.ateSQLException(SQLError.java:943)
sql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
sql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3909)
其实是很简单的, 下⾯的语句中多了个as, 不应该的.
INSERT INTO queue_message_entity_bak AS SELECT queue_message_entity WHERE `insert_time` < ?
本来就是简单的sql 语法错误, 还以为是⽇期格式问题, 搞了⼏个⼩时, 也是郁闷了. 原因还是不够细⼼,
没注意到 BadSqlGrammarException 这个提⽰.
posted on 2018-07-06 09:42 阅读( ...) 评论( ...)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论