报错--->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 'delect from testd

数据库   发布日期:2025年06月05日   浏览次数:309

报错--->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 'delect from testdb.test001 where id=9' at line 1

全部报错:

org.apache.ibatis.exceptions.PersistenceException: 
### Error updating 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 'delect from testdb.test001 where id=9' at line 
### The error may exist in com/xian/dao/UserMapper.java (best guess)
### The error may involve com.xian.dao.UserMapper.delect-Inline
### The error occurred while setting parameters
### SQL: delect from testdb.test001 where id=?
### 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 'delect from testdb.test001 where id=9' at line 
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.delete(DefaultSqlSession.java:)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:)
    at com.sun.proxy.$Proxy8.delect(Unknown Source)
    at MapperTest.delect(MapperTest.java:)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:)
    at java.lang.reflect.Method.invoke(Method.java:)
    at org.junit.runners.model.FrameworkMethod$.runReflectiveCall(FrameworkMethod.java:)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:)
    at org.junit.runners.ParentRunner$.run(ParentRunner.java:)
    at org.junit.runners.ParentRunner$.schedule(ParentRunner.java:)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:)
    at org.junit.runners.ParentRunner.access$(ParentRunner.java:)
    at org.junit.runners.ParentRunner$.evaluate(ParentRunner.java:)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:)
Caused by: 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 'delect from testdb.test001 where id=9' at line 
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:)
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:)
    at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:)
    at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:)
    ...  more

注意我的代码

public interface UserMapper {
    //查询所有
    @Select("select * from testdb.test001")
    List<User> getUserList();
    @Select("select * from testdb.test001 where id=#{id}")
    User getUserById(@Param("id") int id);
    @Insert("insert into testdb.test001 (id,name) values (#{id},#{name})")
    int add(User user);
    @Update("update testdb.test001 set name=#{name} where id=#{id}")
    int updata(User user);
    @Delete("delect from testdb.test001 where id=#{id}")
    int delect(@Param("id") int id);
}

delete拼错了

update拼错了

崩溃

 

以上就是报错--->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 'delect from testd的详细内容,更多关于报错--->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 'delect from testd的资料请关注九品源码其它相关文章!