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 problem with updating records in ms access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "problem with updating records in ms access" Watch "problem with updating records in ms access" New topic

problem with updating records in ms access

JP Estrada
Ranch Hand

Joined: Mar 21, 2006
Posts: 48
Im having this very weird problem with updating records in MS access..
I do this:

stat3.executeUpdate("UPDATE table1 SET weight='" + t.getWeight().trim() + "' WHERE name='" + k + "');

i dont get an exception but the record doesnt get updated..

Then i try this:

r2 = stat3.executeQuery("SELECT * FROM table1 WHERE name='" + t.getName().trim() + "'");;


It doesnt work..

if i setup stat3 as :
stat3 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

I get an invalid cursor state error.

If i set it up as just :
stat3 = con.createStatement();

I dont get an error, but the records still doesnt get updated! Help!

What could be causing this? (the db i'm using is ms access 97)
Edwin Dalorzo
Ranch Hand

Joined: Dec 31, 2004
Posts: 961
When you execute the Statement.executeUpdate(String sql) it should return a number with the count of the affected rows.

When you invoke your...

...does it return a value bigger the 0?

Because if it doesn't, that means that there is nothing wrong with your code, it is just that your are not actually updating anything.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

This is a common problem, search this forum for 'access insert'
I agree. Here's the link:
subject: problem with updating records in ms access
jQuery in Action, 3rd edition