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

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 精通抖音评论点赞接口的来!需要开发
  • ¥15 VB.NET2022如何生成发布成exe文件
  • ¥30 matlab appdesigner私有函数嵌套整合
  • ¥15 给我一个openharmony跑通webrtc实现视频会议的简单demo项目,sdk为12
  • ¥15 vb6.0使用jmail接收smtp邮件并另存附件到D盘
  • ¥30 vb net 使用 sendMessage 如何输入鼠标坐标
  • ¥15 关于freesurfer使用freeview可视化的问题
  • ¥100 谁能在荣耀自带系统MagicOS版本下,隐藏手机桌面图标?
  • ¥15 求SC-LIWC词典!
  • ¥20 有关esp8266连接阿里云