• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java ResultSet

 
Divya Kamath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have tried the following piece of code to view the resultSet in an Access database.

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet res = stmt.executeQuery("select * from tableName);
//code to accept a new column value from the user....
res.UpdateString(/*column name*/);
res.updateRow();

The resultSet gets updated but it also displays the changes made to the database from another transaction. What am i doing wrong?

Thanks
Divya
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you use autocommitted connection?
 
stu derby
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Divya Kamath:
I have tried the following piece of code to view the resultSet in an Access database.

The resultSet gets updated but it also displays the changes made to the database from another transaction. What am i doing wrong?

Thanks
Divya


You're doing nothing wrong.

Access isn't a transactional database, and there's no way to get transactional behavior from it. If you try to use it for a back-end of a multi-threaded application, you need to do extraordinary things to simulate transactionality within your code to prevent data corruption. Personally, I wouldn't even think of trying to do that.

Sorry.
[ February 22, 2006: Message edited by: stu derby ]
 
Divya Kamath
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No i dont have auto commit turned on.
By externally changing the values in the columns i meant that i open the access table and manually modify the values there, save the changes and close access.
i've used the same code (without auto commit) to test the other combinations of types and concurrency adn it works fine for all of them.
In TYPE_SCROLL_INSENSITIVE,CONCUR_READ_ONLY, i display the result set as it is and then while the program is still running i manually change the values in access as i described above and when i print the result set in the same code for the second time, it does not show the change made(being of type insensitive).So it works fine in this case.
But not when i use TYPE_SCROLL_INSENSITVE,CONCUR_UPDATABLE.
Is it a valid combination?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic