Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception raised when trying to delete record from database...!

 
Prakash Chidambaram
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am presently working on a project involving JSP and MSAccess using JDBC-ODBC bridge. I can easily add, modify, view the values. But when i try to delete the same i get the follg. exception
"java.sql.SQLException: [Microsoft][ODBC Microsoft Access 97
Driver]Wrong number of parameters test value"
I don't get it.. Pls. help me to recover from this error.

My Code:
-------
<%@ page language="java" import="java.sql.*,java.io.*" %>
<%!<br /> String k="";<br /> String check="";<br /> String DeleteValues() {<br /> try {<br /> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");<br /> Connection con=DriverManager.getConnection("jdbc dbc:sara","","");<br /> PreparedStatement ps=con.prepareStatement("delete person where name=?");<br /> ps.executeUpdate();<br /> con.close();<br /> }catch (Exception e) {return e.toString();}<br /> return "values deleted from database..";<br /> }<br /> %>
<%<br /> k=request.getParameter("submit");<br /> if (k.equals("Yes")) {<br /> check=request.getParameter("name");<br /> out.println("<body>"+DeleteValues()+"</body>");<br /> out.println("<body>"+check+"</body>");<br /> }<br /> %>
With thanks,
prakash.
 
John Bateman
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi
You never set the value of you input parameter in your query.
Try this..

This now passes John to the (1st) input parameter denoted by the ?.
Hope this helps.
[This message has been edited by Thomas Paul (edited March 02, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic