wood burning stoves 2.0*
The moose likes JDBC and the fly likes Error in updating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error in updating" Watch "Error in updating" New topic
Author

Error in updating

QingLing Poh
Greenhorn

Joined: Jun 15, 2009
Posts: 1
<%@ 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

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags and disable smilies.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 10, 2002
Posts: 60046
    
  65

Moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Madhuri jain
Greenhorn

Joined: Dec 31, 2013
Posts: 1
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)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error in updating
 
Similar Threads
Dynamic Row creation at client side and populating the form bean
IntervalCategoryDataset error in JSP page
I am struggling with this error since 1 week
tag libs
javax.servlet.ServletException: Name java: is not bound in this Context