By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,105 Members | 2,569 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,105 IT Pros & Developers. It's quick & easy.

exception:error in mysql syntax

100+
P: 283
hi evrybdy,
the problem is:-
i had this running before in jsp but when i changed the jsp page using struts tags there occoured a problem...
when i enter values in the 2 text boxes and click enter an exception occours which is-
Expand|Select|Wrap|Line Numbers
  1. type Exception report
  2.  
  3. message 
  4.  
  5. description The server encountered an internal error () that prevented it from fulfilling this request.
  6.  
  7. exception 
  8.  
  9. javax.servlet.ServletException: 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 '' at line 1
  10.     org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
  11.     org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
  12.     org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
  13.     org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
  14.     org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
  15.     javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
  16.     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  17.  
  18.  
  19. root cause 
  20.  
  21. com.mysql.jdbc.exceptions.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 '' at line 1
  22.     com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
  23.     com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
  24.     com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
  25.     com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
  26.     com.mysql.jdbc.Connection.execSQL(Connection.java:3250)
  27.     com.mysql.jdbc.Statement.executeUpdate(Statement.java:1355)
  28.     com.mysql.jdbc.Statement.executeUpdate(Statement.java:1270)
  29.     org.apache.tomcat.dbcp.dbcp.DelegatingStatement.executeUpdate(DelegatingStatement.java:225)
  30.     publicity.UpBdgtAction.execute(UpBdgtAction.java:52)
  31.     org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
  32.     org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
  33.     org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
  34.     org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
  35.     javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
  36.     javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
  37.  
  38.  
  39. note The full stack trace of the root cause is available in the Apache Tomcat/5.5.23 logs.
  40.  
  41. --------------------------------------------------------------------------------
  42.  
  43. Apache Tomcat/5.5.23
  44.  
how is this possible??? coz it was running smoothly when it was plain html
herz my sql query which is in my class:-
Expand|Select|Wrap|Line Numbers
  1. String s8 = "INSERT INTO Budget_Master(Branch,Publicity_Code,Budget_Alloted,Work_In_Progress,Amount_Paid) VALUES (?,?,?,?,?)";
  2.  String s9 = "update budget_master set old_budget = budget_alloted where branch='" + s3 + "' and publicity_Code=" + s4;
  3. String s10 = "UPDATE Budget_Master set budget_alloted=" + s5 + " where Branch='" + s3 + "' and publicity_Code=" + s4;
  4.  
  5.  
y is this happening...i wud appreciate ur help..thanx in advance..
regards,
ajos
Sep 27 '07 #1
Share this Question
Share on Google+
1 Reply


Atli
Expert 5K+
P: 5,058
Hi ajos.

I think this i happening because the s3 variable has no value.

If you take a look at the Exception messages, you will see a MySQL error, which is complaining about an error in the syntax, indicating that there is an empty set of single quote-marks (either that or an empty query. Not sure about these JSP errors).

Are you sure all your variables have a value, and that all your queries are being created correctly?
Sep 29 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.