File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem with updating records in ms access" Watch "problem with updating records in ms access" New topic
Author

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() + "'");
r2.next();

r2.updateString("weight",t.getWeight().trim());
r2.updateRow();


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
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is a common problem, search this forum for 'access insert'
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem with updating records in ms access
 
Similar Threads
Problem with Batch
resultset problem
jframe not accepting sql query..
Why it fails to update record
Passing a recordset to a class