qq_24555079
jc小成
采纳率44.4%
2017-04-08 03:48

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

10
已采纳

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条回答

  • qq_35945050 一颗星辰 4年前

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

    点赞 评论 复制链接分享
  • qq_38250166 qq_38250166 4年前

    目测没有问题,如果担心用程序模拟器模拟一下

    点赞 评论 复制链接分享
  • qq_32295869 qq_32295869 4年前

    这么短是没有问题的。我写过比这个更长的

    点赞 评论 复制链接分享
  • kevin8290 kevin-java 4年前

    把sql语句放在mysql表中试一试

    点赞 评论 复制链接分享
  • qq_24555079 jc小成 4年前

    图片说明

    这是是sql语句

    点赞 评论 复制链接分享

相关推荐