• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in updating

 
QingLing Poh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Record Updated</title>
</head>

<body>



<%
String varProductID=request.getParameter("productID");
String varProductCat=request.getParameter("category");
String varProductName=request.getParameter("productName");
String varProductDescription=request.getParameter("productDescription");
String varProductPrice=request.getParameter("productPrice");

Connection con = null;

String source = "jdbcdbcriver={Microsoft Access Driver (*.mdb)}; DBQ=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\ROOT\\project\\project.mdb";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

con = DriverManager.getConnection(source);

Statement stmt = con.createStatement();

String updStmt="Update product Set category='"+varProductCat+"', productName='"+varProductName+"', productDescription='"+varProductDescription+"', productPrice="+varProductPrice+" WHERE (productID="+varProductID+")";

stmt.executeUpdate(updStmt);

con.close();
%>
Record Updated

</body>
</html>






This is my coding,, but it show error stating as below..



org.apache.jasper.JasperException: Exception in JSP: /project/Administrator/processUpdateProduct.jsp:32

29:
30: String updStmt="Update product Set category='"+varProductCat+"', productName='"+varProductName+"', productDescription='"+varProductDescription+"', productPrice="+varProductPrice+" WHERE (productID="+varProductID+")";
31:
32: stmt.executeUpdate(updStmt);
33:
34: con.close();
35: %>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:506)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'blah blah blah'.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:843)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.project.Administrator.processUpdateProduct_jsp._jspService(processUpdateProduct_jsp.java:88)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'blah blah blah'.
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(Unknown Source)
sun.jdbc.odbc.JdbcOdbcStatement.execute(Unknown Source)
sun.jdbc.odbc.JdbcOdbcStatement.executeUpdate(Unknown Source)
org.apache.jsp.project.Administrator.processUpdateProduct_jsp._jspService(processUpdateProduct_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags and disable smilies.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you dump the actual SQL and try running it by hand?

You've hopefully guarded against SQL injection attacks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65119
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
Madhuri jain
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i got this error when running program... when i want to update new data below error will occur... please help me...



Exception report

message javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:549)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:912)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:841)
org.apache.jsp.saveToDatabase_jsp._jspService(saveToDatabase_jsp.java:170)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Error in row
sun.jdbc.odbc.JdbcOdbcResultSet.setPos(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.insertRow(Unknown Source)
org.apache.jsp.saveToDatabase_jsp._jspService(saveToDatabase_jsp.java:149)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic