weixin_45965756
Aias_小枫
采纳率66.7%
2019-12-09 20:34

javaweb小项目,写添加功能时出错了检查了几遍sql没找到错误,但从报错信息来看是sql写错了?

在写emp这张表的添加功能时遇到错误了,但是找不到解决的办法。。。。
sql语句检查好几遍了,也找不到是哪里错了。
下面是图和错误信息。
图片说明图片说明图片说明图片说明图片说明图片说明图片说明图片说明图片说明图片说明

错误信息:在表单页面点击立即提交就报错

[2019-12-09 08:10:13,721] Artifact 人事工资管理系统(psms):war exploded: Artifact is being deployed, please wait...
09-Dec-2019 20:10:14.925 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.jasper.servlet.TldScanner.scanJars 至少有一个JAR被扫描用于TLD但尚未包含TLD。 为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。 在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。
[2019-12-09 08:10:15,033] Artifact 人事工资管理系统(psms):war exploded: Artifact is deployed successfully
[2019-12-09 08:10:15,033] Artifact 人事工资管理系统(psms):war exploded: Deploy took 1,312 milliseconds
DEBUG [http-nio-555-exec-5] - Logging initialized using 'class org.apache.ibatis.logging.log4j.Log4jImpl' adapter.
DEBUG [http-nio-555-exec-5] - PooledDataSource forcefully closed/removed all connections.
DEBUG [http-nio-555-exec-5] - PooledDataSource forcefully closed/removed all connections.
DEBUG [http-nio-555-exec-5] - PooledDataSource forcefully closed/removed all connections.
DEBUG [http-nio-555-exec-5] - PooledDataSource forcefully closed/removed all connections.
DEBUG [http-nio-555-exec-5] - Opening JDBC Connection
DEBUG [http-nio-555-exec-5] - Created connection 1428244206.
DEBUG [http-nio-555-exec-5] - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-5] - ==>  Preparing: select * from emp where username=? and password=? 
DEBUG [http-nio-555-exec-5] - ==> Parameters: root(String), aias(String)
DEBUG [http-nio-555-exec-5] - <==      Total: 1
DEBUG [http-nio-555-exec-5] - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-5] - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-5] - Returned connection 1428244206 to pool.
09-Dec-2019 20:10:23.398 信息 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory 把web 应用程序部署到目录 [C:\apache-tomcat-9.0.27-windows-x64\apache-tomcat-9.0.27\webapps\manager]
09-Dec-2019 20:10:23.482 信息 [Catalina-utility-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\apache-tomcat-9.0.27-windows-x64\apache-tomcat-9.0.27\webapps\manager] has finished in [83] ms
DEBUG [http-nio-555-exec-10] - Opening JDBC Connection
DEBUG [http-nio-555-exec-10] - Checked out connection 1428244206 from pool.
DEBUG [http-nio-555-exec-10] - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-10] - ==>  Preparing: select max(id) from emp 
DEBUG [http-nio-555-exec-10] - ==> Parameters: 
DEBUG [http-nio-555-exec-10] - <==      Total: 1
DEBUG [http-nio-555-exec-10] - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-10] - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-10] - Returned connection 1428244206 to pool.
DEBUG [http-nio-555-exec-10] - Opening JDBC Connection
DEBUG [http-nio-555-exec-10] - Checked out connection 1428244206 from pool.
DEBUG [http-nio-555-exec-10] - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-10] - ==>  Preparing: insert into emp(id,empno,username,password,ename,sex,birthday,email,call,pname,deptno,state,permissions) values (?,?,?,?,?,?,?,?,?,?,?,?,?) 
DEBUG [http-nio-555-exec-10] - ==> Parameters: 28(Integer), 028(String), test(String), test(String), 测试(String), 男(String), 2019-12-09(String), 777777777@qq.com(String), 11111111111(String), 接待员(String), 001(String), 在职(String), 普通员工(String)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
DEBUG [http-nio-555-exec-10] - Rolling back JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
    at java.lang.reflect.Method.invoke(Method.java:498)
DEBUG [http-nio-555-exec-10] - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
DEBUG [http-nio-555-exec-10] - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@552146ee]
    at com.cdx.psms.utils.TransactionInvocationHandler.invoke(TransactionInvocationHandler.java:30)
DEBUG [http-nio-555-exec-10] - Returned connection 1428244206 to pool.
    at com.sun.proxy.$Proxy5.add(Unknown Source)
    at com.cdx.psms.controller.Emp_InsertAddServlet.doPost(Emp_InsertAddServlet.java:46)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: 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 'call,pname,deptno,state,permissions)
        values
        (28,'028','test','te' at line 2
### The error may exist in com/cdx/psms/mapper/EmpMapper.xml
### The error may involve emp.add-Inline
### The error occurred while setting parameters
### SQL: insert into         emp(id,empno,username,password,ename,sex,birthday,email,call,pname,deptno,state,permissions)         values         (?,?,?,?,?,?,?,?,?,?,?,?,?)
### Cause: 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 'call,pname,deptno,state,permissions)
        values
        (28,'028','test','te' at line 2
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
    at com.cdx.psms.dao.EmpDaoImpl.add(EmpDaoImpl.java:42)
    at com.cdx.psms.service.EmpServiceImpl.add(EmpServiceImpl.java:26)
    ... 31 more
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 'call,pname,deptno,state,permissions)
        values
        (28,'028','test','te' at line 2
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:944)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3933)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3869)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2524)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2675)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1912)
    at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1251)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59)
    at com.sun.proxy.$Proxy7.execute(Unknown Source)
    at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:47)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)
    at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)
    at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)
    at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:197)
    ... 34 more
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

4条回答

  • zqbnqsdsmd zqbnqsdsmd 2年前
  • u010827544 KimiKudo 2年前

    把语句放到Navicat里执行一下看报不报错,看起来应该是字段与关键字重名了的问题,类似问题先把SQL执行一下问题就会很明显.

    点赞 评论 复制链接分享
  • weixin_43737036 灵动领域 2年前

    看你的报错信息,应该是表字段里面的call的问题,call是mysql的关键字,你把这个字段换了试下应该就好了。

    点赞 评论 复制链接分享
  • weixin_47237043 z_Chirshu 2月前

    call为mysql保留关键字,需要加上`call`,或者更改字段名

    点赞 评论 复制链接分享