You have an error in your SQL syntax; check the manual that corresponds to your

Embe 2016-03-02 11:13:55
错误
### The error may involve com.cuit.admin.dao.SystemManageDao.getAdminGrantsByRole-Inline
### The error occurred while setting parameters
### SQL: select ami.no no, ami.name name, ami.url url, ami.active menu_active, ami.level level, ami.sequence sequence, ami.parent_no parent_no, ami.create_date createDate, ami.update_date updateDate, armgv.active active, armgv.create 'create', armgv.view 'view', armgv.update 'update', armgv.delete 'delete' from admin_menu_info ami left join (select * from admin_role_menu_grant_view where role_no=#no#) armgv on armgv.menu_no = ami.no order by ami.modelid, ami.level, ami.sequence
### 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 'order by ami.modelid, ami.level, ami.sequence' at line 17
; 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 'order by ami.modelid, ami.level, ami.sequence' at line 17
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:233)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy27.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:195)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at com.sun.proxy.$Proxy28.getAdminGrantsByRole(Unknown Source)
at com.cuit.admin.service.impl.SystemManageSerImpl.getAdminGrantsByRole(SystemManageSerImpl.java:199)
at com.cuit.admin.service.impl.SystemManageSerImpl$$FastClassByCGLIB$$66e4577a.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:688)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:621)
at com.cuit.admin.service.impl.SystemManageSerImpl$$EnhancerByCGLIB$$ff0d74d7.getAdminGrantsByRole(<generated>)
at com.cuit.web.security.MySecurityMetadataSource.loadResourceDefine(MySecurityMetadataSource.java:49)
at com.cuit.web.security.MySecurityMetadataSource.<init>(MySecurityMetadataSource.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:108)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1003)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:907)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1325)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
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 'order by ami.modelid, ami.level, ami.sequence' at line 17
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)
... 74 more


代码
<select id="getAdminGrantsByRole" parameterType="adminRole" resultMap="adminGrantMap">
<![CDATA[
select ami.no no,
ami.name name,
ami.url url,
ami.active menu_active,
ami.level level,
ami.sequence sequence,
ami.parent_no parent_no,
ami.create_date createDate,
ami.update_date updateDate,
armgv.active active,
armgv.create 'create',
armgv.view 'view',
armgv.update 'update',
armgv.delete 'delete'
from admin_menu_info ami
left join (select * from admin_role_menu_grant_view where role_no=#no#) armgv on armgv.menu_no = ami.no
order by ami.modelid, ami.level, ami.sequence
]]>
</select>
...全文
267 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Intboy 2016-03-02
  • 打赏
  • 举报
回复
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 'order by ami.modelid, ami.level, ami.sequence' at line 17 把sql拿出来放mysql里面运行试试
chen222246lei 2016-03-02
  • 打赏
  • 举报
回复
1. 看上去语法并没有错,只是#no#是不是你传入的变量?(我对开发不太懂,字段应该不能以#开头) 2. 在mysql中执行该SQL语句是否能正常显示所有的查询结果而不报错(是显示所有的查询记录) 3. 在你的SQL语句的最后加一个";"号, 即order by ami.modelid, ami.level, ami.sequence 改为 order by ami.modelid, ami.level, ami.sequence; 4. 如果仍然报错把SQL语句修改为 select ami.no no, ami.name name, ami.url url, ami.active menu_active, ami.level level, ami.sequence sequence, ami.parent_no parent_no, ami.create_date createDate, ami.update_date updateDate, armgv.active active, armgv.create 'create', armgv.view 'view', armgv.update 'update', armgv.delete 'delete' from admin_menu_info ami, (select * from admin_role_menu_grant_view where role_no=#no#) armgv where armgv.menu_no = ami.no order by ami.modelid, ami.level, ami.sequence; 再次测试下是否还报错,这两个SQL的语义是不一样的,这里只是做个测试.
Embe 2016-03-02
  • 打赏
  • 举报
回复
引用 2 楼 rui888 的回复:
ami.no order by 难道order 前面没有空格,你把sql 截取出来放到mysql 环境中测试看看。
我在mysql下面都是可以查出来的,是正确的,但是一运行就要报语法错误,。。。。。。。。。。。。。
tony4geek 2016-03-02
  • 打赏
  • 举报
回复
ami.no order by 难道order 前面没有空格,你把sql 截取出来放到mysql 环境中测试看看。
Embe 2016-03-02
  • 打赏
  • 举报
回复
求大神告诉我哪里mysql语法错了啊,我感觉没错啊
Royal_lr 2016-03-02
  • 打赏
  • 举报
回复
将sql套到数据库中执行下就知道了,,,
Embe 2016-03-02
  • 打赏
  • 举报
回复
解决了,就是语法错误。role_no=#no# ,是这个写法是ibatis,mybatis是这样写的role_no=#{no}
tony4geek 2016-03-02
  • 打赏
  • 举报
回复
引用 3 楼 u012161563 的回复:
[quote=引用 2 楼 rui888 的回复:] ami.no order by 难道order 前面没有空格,你把sql 截取出来放到mysql 环境中测试看看。
我在mysql下面都是可以查出来的,是正确的,但是一运行就要报语法错误,。。。。。。。。。。。。。[/quote]难道是驱动版本问题? 看不出来

67,514

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧