- 在写完了控制层,服务层和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;
在后面查询中我用到了这个片段,拼接后多出来的分号导致语法错误,无法顺利执行,非常低级的错误,记录下来供反思。



