码迷,mamicode.com
首页 > 其他好文 > 详细

错误: nknown column 'xxxx' in 'where clause'

时间:2017-10-25 18:36:29      阅读:288      评论:0      收藏:0      [点我收藏+]

标签:generated   eclipse   oda   tin   单引号   oca   ping   select   2.0   

nknown column ‘sdsds‘ in ‘where clause‘

 

 运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse

错误:nknown column ‘sdsds‘ in ‘where clause‘

错误原因:数据库查询无用,可能很多写sql语句都会遇到這个问题,从字面这意思很容易得出,意思是列名不存在的意思,在下面我的数据库根本没有這个所谓的列名,這个是因为我在查询sql语句时候用到字符以及整形等,這里改成整型就没有问题

解决办法:你查询时候在对应的字符型没有加上对应的单引号

错误代码:

 1 ### SQL: SELECT student_id as studentId,student_password as studentPassword  FROM xxhh_table_user    WHERE student_id=15301061 AND student_password=sdsds
 2 ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘sdsds‘ in ‘where clause‘
 3 ; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column ‘sdsds‘ in ‘where clause‘
 4     at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
 5     at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
 6     at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
 7     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
 8     at com.sun.proxy.$Proxy15.selectOne(Unknown Source)
 9     at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
10     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:68)
11     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:52)
12     at com.sun.proxy.$Proxy21.selectByPrimaryKey(Unknown Source)
13     at com.xxhh.service.impl.LoginServiceImpl.selectByPrimaryKey(LoginServiceImpl.java:77)
14     at com.xxhh.controller.LoginController.selectUserAndPassword(LoginController.java:126)
15     at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
16     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
17     at java.lang.reflect.Method.invoke(Method.java:601)
18     at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
19     at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
20     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
21     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
22     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
23     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
24     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
25     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
26     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
27     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:868)

 

相关代码:

  技术分享

 

错误: nknown column 'xxxx' in 'where clause'

标签:generated   eclipse   oda   tin   单引号   oca   ping   select   2.0   

原文地址:http://www.cnblogs.com/tanglie/p/7731455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!