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 syntax"ErrorSQL
- 萬能方法解決——You have an error in your SQL syntaxErrorSQL
- 錯誤內容:You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverErrorMySqlServer
- 帝國CMS安裝時出現You have an error in your SQL syntax錯誤程式碼的解決方法ErrorSQL
- git在pull時報錯You have not concluded your mergeGit
- git-----You have not concluded your merge (MERGE_HEAD exists)解決Git
- Do you wish to have better graphics?
- Caused by: Error: ' ' is not a valid resource name characterError
- Would you like to develop a story for your character?dev
- Third season twentieth episode,do you have a dollhouse?
- You have new mail in /var/spool/mail/rootAI
- ou have not concluded your merge (MERGE_HEAD exists)
- studio if you already have a 64-bit JDK installedJDK
- 網站提示:You Don’t Have Permission To Access網站
- You don't have write permissions for the /usr/bin directory.
- E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packagesErrorPackage
- error: invalid type argument of unary ‘*‘ (have ‘int‘) *__first = __tmp;Error
- ERROR 1410 (42000): You are not allowed to create a user with GRANTError
- paramiko 2.4.2 has requirement cryptography>=1.5, but you'll have cryptography 1.3.1 which is incompUIREM
- Make sure you configure your "user.name" and "user.email" in git.AIGit
- pytest報錯Hint: make sure your test modules/packages have valid Python names.PackagePython
- MySQL:You must reset your password using ALTER USER statement before executing this statement.MySql
- Mongodb安裝坑 - Service 'MongoDB Server' (MongDB) failed to start. Verify that you have...MongoDBServerAI
- 安裝ROS出現 Unable to Correct Problems ‘You have Held Broken Packages’ 錯誤ROSPackage
- Android error “Could not get BatchedBridge, make sure your bundle is packaged properly” on start ofAndroidErrorBATPackage
- 解決 Git 更新本地衝突:commit your changes or stash them before you can mergeGitMIT
- 執行git命令時出現Please make sure you have the correct access rights and the repository existsGit
- Microsoft SQL Server, Error: 15128 ()ROSSQLServerError
- vs code jshint報錯或者Open browser failed!! Please check if you have installed the browser correctly!錯誤.JSAI
- Server-side activities have been updated. You need to restart SharePoint Designer to use the updated version of activities.ServerIDEREST
- 切換分支 error: Your local changes tby checkout: 錯誤解決方法Error
- git pull遇到錯誤:error: Your local changes to the following files would be overwritten by merge:GitError
- 解決報錯 cuDNN error: CUDNN_STATUS_NOT_SUPPORTED. This error may appear if you passed in a non-contiguous input.DNNErrorAPP
- merge sql error, dbType sqlserver, druid1.1.10, sql : nullSQLErrorServerUINull
- Git更新本地倉庫及衝突"Commit your changes or stash them before you can merge"解決GitMIT
- Git push時報錯:fatal: Could not read from remote repository. Please make sure you have the correct access rightsGitREM
- ReactNative執行報錯Command `run-android` unrecognized. Make sure that you have run `npm install` and tha...ReactAndroidZedNPM
- Caused by: java.sql.SQLException: Access denied for user 'dell-pc'@'xxxxx' (using password: YES)JavaSQLException