Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL
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 ‘username=’**’’ at line 1
從報錯資訊能看出原因是出在我們書寫sql語句時,沒有編寫規範,導致讀取執行對映配置檔案sqlMapper出現錯誤,導致失敗。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.UserMapper">
<select id="findByCondition" parameterType="com.itheima.domain.User" resultType="com.itheima.domain.User">
select * from user where id=#{id}and username=#{username};
</select>
</mapper>
經過仔細核查發現發現select * from user where id=#{id}and username=#{username};缺少空格
修改後
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.itheima.mapper.UserMapper">
<select id="findByCondition" parameterType="com.itheima.domain.User" resultType="com.itheima.domain.User">
select * from user where id=#{id} and username=#{username};
</select>
</mapper>
執行成功
成功讀取資料庫表中Data
我不能保證我所說的都是對的,但我能保證每一篇都是用心去寫的,我始終認同: “分享的越多,你的價值增值越大”,我們一同在分享中進步,在分享中成長,越努力越幸運。再分享一句話“十年前你是誰,一年前你是誰,甚至昨天你是誰,都不重要。重要的是,今天你是誰,以及明天你將成為誰。”
人生贏在轉折處,改變從現在開始!
支援我的朋友們記得點波推薦哦,您的肯定就是我前進的動力。
作者:T,Joker.田總
微信公眾號:田爸爸服務號
有事Q我:1728569609 後期我會將交流群分享出來
本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段宣告,且在文章頁面明顯位置給出原文連結,否則保留追究法律責任的權利。
相關文章
- 萬能方法解決——You have an error in your SQL syntaxErrorSQL
- Hibernate 與 MySql 資料庫關鍵字衝突You have an error in your SQL syntax; check the manualMySql資料庫Error
- git-----You have not concluded your merge (MERGE_HEAD exists)解決Git
- You have new mail in /var/spool/mail/rootAI
- Would you like to develop a story for your character?dev
- redhat your system appears to have shut down uncleanlyRedhatAPP
- 網站提示:You Don’t Have Permission To Access網站
- do not have permission to view information for any of the hosts you requestedViewORM
- Caused by: Error: ' ' is not a valid resource name characterError
- You don't have write permissions for the /usr/bin directory.
- You do not have permission to get URL ‘/’ from this server解決方案Server
- wamp出現You don’t have permission to access/on this server提示Server
- The virtual hostname(s), racvip02, you have specified appearsAPP
- If you cannot remember your password for Recovery and Rescue for IBM LaptopREMIBMAPT
- studio if you already have a 64-bit JDK installedJDK
- 【MySQL】ERROR 1093 You canMySqlError
- [php排錯] Forbidden You don't have permission to access / on this server.PHPORBServer
- Couldn't be opened because you don't have permission to view it 執行時報錯View
- mac osx Forbidden You don't have permission to access / on this server解決方法MacORBServer
- centos 老出現You have new mail in /var/spool/mail/root 解決CentOSAI
- 去掉linux中"You have new mail in /var/spool/mail/root"的提示LinuxAI
- Software caused connection abort: socket write error/mysql/tomcatErrorMySqlTomcat
- error: invalid type argument of unary ‘*‘ (have ‘int‘) *__first = __tmp;Error
- Mongodb安裝坑 - Service 'MongoDB Server' (MongDB) failed to start. Verify that you have...MongoDBServerAI
- paramiko 2.4.2 has requirement cryptography>=1.5, but you'll have cryptography 1.3.1 which is incompUIREM
- 安裝ROS出現 Unable to Correct Problems ‘You have Held Broken Packages’ 錯誤ROSPackage
- ORA-01555 caused by SQL statement belowSQL
- 裝nagios報You don't have permission to access /nagios/ on this server. 錯誤iOSServer
- Your password has expired. To log in you must change it using a client that supports expired passworclient
- Make sure you configure your "user.name" and "user.email" in git.AIGit
- 安裝linux作業系統時出現“you have not created a /boot/efi partition”Linux作業系統boot
- Git衝突:commit your changes or stash them before you can merge.GitMIT
- pytest報錯Hint: make sure your test modules/packages have valid Python names.PackagePython
- Toad識別64bit Oracle問題 - You do not have any Oracle homes installedOracle
- SQL Server wanting, start your journey now!SQLServer
- How to prevent blocking in your SQL Server databaseBloCSQLServerDatabase
- 執行git命令時出現Please make sure you have the correct access rights and the repository existsGit
- ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default valueError