File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Deleting from a MS Access Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Deleting from a MS Access Database" Watch "Deleting from a MS Access Database" New topic

Deleting from a MS Access Database

Femi Ojambati

Joined: Aug 13, 2008
Posts: 6
Please, I have a problem with deleting a row from in a table in a database.
This is my code:

public class CooperativeDB{

String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String host = "jdbcdbc:CTCS Database";
Connection conn = null;
public static void main(String [] args){
Class.forName (driver);
conn = DriverManager.getConnection(host, "", "");
stat = conn.createStatement();

String stringUpdate = "DELETE FROM Loan WHERE Member_ID_No = ?"
PreparedStatement ps = conn.prepareStatement(stringUpdate);
}catch(Exception e){
When I ran it, this messages were displayed:
[Ljava.lang.StackTraceElement;@1389e4 java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.

Please, help me check the code
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46349
Don't know. I don't think the Exception is occurring where you think it is. Please check the stack trace for line numbers and where the Exception is occurring. Use exc.printStackTrace(), not getStackTrace().

Please use the code button; your code is difficult to read. And please post real code; I can see a compiler error in what you have posted at a � minute look.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

That message typically occurs in Access when you use a table name which isn't in the database you are connected to, and when you use a column name which isn't in the table you are using.

So that would mean you misspelled the table name or the column name. Or you connected to the wrong database.

By the way the standard way of printing the stack trace is this:
I agree. Here's the link:
subject: Deleting from a MS Access Database
It's not a secret anymore!