This error was reported when configuring the MyBatis Framework test:
The following is the wrong message:
Org.apache.ibatis.exceptions.PersistenceException:
# # # Error querying database. Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' SELECT * from user wh Ere uid=1 ' at line 1
# # # The error may exist in Sqlmap/user.xml
# # # The error may involve test. Selectuserbyid-inline
# # # The error occurred while setting parameters
# # # Sql:select * from user where uid=?
# # # Cause:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' SELECT * from user wh Ere uid=1 ' at line 1
At Org.apache.ibatis.exceptions.ExceptionFactory.wrapException (exceptionfactory.java:26)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:111)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:102)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne (defaultsqlsession.java:66)
At Test. Mybatisdemo.test1 (mybatisdemo.java:23)
At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
At Sun.reflect.NativeMethodAccessorImpl.invoke (Unknown Source)
At Sun.reflect.DelegatingMethodAccessorImpl.invoke (Unknown Source)
At Java.lang.reflect.Method.invoke (Unknown Source)
At Org.junit.runners.model.frameworkmethod$1.runreflectivecall (frameworkmethod.java:50)
At Org.junit.internal.runners.model.ReflectiveCallable.run (reflectivecallable.java:12)
At org.junit.runners.model.FrameworkMethod.invokeExplosively (frameworkmethod.java:47)
At Org.junit.internal.runners.statements.InvokeMethod.evaluate (invokemethod.java:17)
At Org.junit.runners.ParentRunner.runLeaf (parentrunner.java:325)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:78)
At Org.junit.runners.BlockJUnit4ClassRunner.runChild (blockjunit4classrunner.java:57)
At Org.junit.runners.parentrunner$3.run (parentrunner.java:290)
At Org.junit.runners.parentrunner$1.schedule (parentrunner.java:71)
At Org.junit.runners.ParentRunner.runChildren (parentrunner.java:288)
At org.junit.runners.parentrunner.access$000 (parentrunner.java:58)
At Org.junit.runners.parentrunner$2.evaluate (parentrunner.java:268)
At Org.junit.runners.ParentRunner.run (parentrunner.java:363)
At Org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (junit4testreference.java:86)
At Org.eclipse.jdt.internal.junit.runner.TestExecution.run (testexecution.java:38)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:459)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (remotetestrunner.java:675)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (remotetestrunner.java:382)
At Org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (remotetestrunner.java:192)
caused By:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:You has an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near ' SELECT * from user wh Ere uid=1 ' at line 1
At Sun.reflect.NativeConstructorAccessorImpl.newInstance0 (Native Method)
At Sun.reflect.NativeConstructorAccessorImpl.newInstance (Unknown Source)
At Sun.reflect.DelegatingConstructorAccessorImpl.newInstance (Unknown Source)
At Java.lang.reflect.Constructor.newInstance (Unknown Source)
At Com.mysql.jdbc.Util.handleNewInstance (util.java:409)
At Com.mysql.jdbc.Util.getInstance (util.java:384)
At Com.mysql.jdbc.SQLError.createSQLException (sqlerror.java:1052)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:4232)
At Com.mysql.jdbc.MysqlIO.checkErrorPacket (mysqlio.java:4164)
At Com.mysql.jdbc.MysqlIO.sendCommand (mysqlio.java:2615)
At Com.mysql.jdbc.MysqlIO.sqlQueryDirect (mysqlio.java:2776)
At Com.mysql.jdbc.ConnectionImpl.execSQL (connectionimpl.java:2838)
At Com.mysql.jdbc.PreparedStatement.executeInternal (preparedstatement.java:2082)
At Com.mysql.jdbc.PreparedStatement.execute (preparedstatement.java:1307)
At Org.apache.ibatis.executor.statement.PreparedStatementHandler.query (preparedstatementhandler.java:59)
At Org.apache.ibatis.executor.statement.RoutingStatementHandler.query (routingstatementhandler.java:73)
At Org.apache.ibatis.executor.SimpleExecutor.doQuery (simpleexecutor.java:60)
At Org.apache.ibatis.executor.BaseExecutor.queryFromDatabase (baseexecutor.java:267)
At Org.apache.ibatis.executor.BaseExecutor.query (baseexecutor.java:137)
At Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:96)
At Org.apache.ibatis.executor.CachingExecutor.query (cachingexecutor.java:77)
At Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (defaultsqlsession.java:108)
... + More,
I'll post my mapper file, and you should be able to reflect the cause of the mistake.
<select id= "Selectuserbyid" resulttype= "Vo. User "parametertype=" int ">
SELECT * from user where Uid=#{uid}
</select>
Summarize the cause of the error:
User is a keyword in the MySQL database, so there will be an error in the SQL statement
MySQL Check the manual that corresponds to your MySQL server version for the right syntax error