jc小成 2017-04-08 03:48 采纳率: 44.4%
浏览 1613
已采纳

JDBC sql语句有没有限制字符?

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.jdbc.BadSqlGrammarException:

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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1

The error may involve com.exam.dao.TeacherDao.readIn-Inline

The error occurred while setting parameters

SQL: insert into read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,R_Option1C,R_Option1D,R_Question1Answer,R_Question2,R_Option2A,R_Option2B,R_Option2C,R_Option2D,R_Question2Answer,R_Question3,R_Option3A,R_Option3B,R_Option3C,R_Option3D,R_Question3Answer,R_Question4,R_Option4A,R_Option4B,R_Option4C,R_Option4D,R_Question4Answer,R_Num,R_Time,R_T_Sn) values(default,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,default,?,?)

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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1

; bad SQL grammar []; nested exception is 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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

root cause

org.springframework.jdbc.BadSqlGrammarException:

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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1

The error may involve com.exam.dao.TeacherDao.readIn-Inline

The error occurred while setting parameters

SQL: insert into read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,R_Option1C,R_Option1D,R_Question1Answer,R_Question2,R_Option2A,R_Option2B,R_Option2C,R_Option2D,R_Question2Answer,R_Question3,R_Option3A,R_Option3B,R_Option3C,R_Option3D,R_Question3Answer,R_Question4,R_Option4A,R_Option4B,R_Option4C,R_Option4D,R_Question4Answer,R_Num,R_Time,R_T_Sn) values(default,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,default,?,?)

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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1

; bad SQL grammar []; nested exception is 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 'read(R_No,R_Grade,R_Section,R_Level,R_Content,R_Question1,R_Option1A,R_Option1B,' at line 1
org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)

我在写insert语句时候 想往表里插入一条数据,表字段有三十二个,插入时候就出现上面的问题了。  sql语句没有问题,还就是在mysql手动往表里面插入也没有问题,所以我绝得应该是jdbc 对sql语句有限制。不知道有人能解决吗?![图片说明](https://img-ask.csdn.net/upload/201704/08/1491623575_158675.jpg)
  • 写回答

5条回答 默认 最新

  • 一颗星辰 2017-04-10 06:08
    关注

    没有 JDBC 就是 写起来不方便 但是他的基本功能还是很6的 你先看看你SQL在数据库直接写 有没有问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab