Reputation: 123
I am currently trying to update a record using Java Netbeans into a MS Access Database and i keep on getting the following error:
ERROR: net.ucanaccess.jdbc.UcanaccessSQLException: user lacks privilege or object not found: WHERE
The following is my code:
public void Edit(Customer a, int id) {
con = DBConnect();
String sql = "Update Customer set CName =?,CAge =?,CPhone =?,CAddress =?, CGender =?, WHERE [ID] =" + id + "";
try {
s = con.prepareStatement(sql);
s.setString(1, a.getName());
s.setString(2, a.getAge());
s.setString(3, a.getContact());
s.setString(4, a.getAddress());
s.setString(5, a.getGender());
s.executeUpdate();
JOptionPane.showMessageDialog(null, "Customer profile Updated");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
Upvotes: 1
Views: 4372
Reputation: 118
This error usually happens when you often mistype the query. Double check the syntax of the query. It will solve the error surely.
Upvotes: 0
Reputation: 123399
Your problem is the comma immediately before the WHERE keyword. You need to remove it. That is, change
CGender =?, WHERE
to
CGender =? WHERE
Upvotes: 1