栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SQL BUG - java.sql.SQLSyntaxErrorException -已解决

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SQL BUG - java.sql.SQLSyntaxErrorException -已解决

SQL BUG - java.sql.SQLSyntaxErrorException -已解决
  • 在写完了控制层,服务层和mapper层和sql语句后,启动服务器爆了以下错误:
### Error querying database.  Cause: java.sql.SQLSyntaxErrorException: 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 'WHERe ADMIN_NAME = 'admin' and ADMIN_PWD = 'admin'' at line 1
### The error may exist in file [E:workcodesshoptargetshop-1.0-SNAPSHOTWEB-INFclassesmapperAdminMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: select admin_id, admin_name, admin_pwd, admin_realname, admin_email         from t_admin;                WHERe ADMIN_NAME = ? and ADMIN_PWD = ?
### Cause: java.sql.SQLSyntaxErrorException: 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 'WHERe ADMIN_NAME = 'admin' and ADMIN_PWD = 'admin'' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 'WHERe ADMIN_NAME = 'admin' and ADMIN_PWD = 'admin'' at line 1] with root cause
	java.sql.SQLSyntaxErrorException: 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 'WHERe ADMIN_NAME = 'admin' and ADMIN_PWD = 'admin'' at lin

提示我sql语句语法出错了,

 Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;

并告诉我在这附近:

near 'WHERe ADMIN_NAME = 'admin' and ADMIN_PWD = 'admin'' at line 1

仔细检查后发现:在我的sql标签中,我在结束时候习惯性的加了分号 “;” ,在去点该分号后,不再报错。

    
        select admin_id, admin_name, admin_pwd, admin_realname, admin_email from t_admin;
    

    

在后面查询中我用到了这个片段,拼接后多出来的分号导致语法错误,无法顺利执行,非常低级的错误,记录下来供反思。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1036186.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号