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
Joined: Oct 09, 2002
Posts: 294
posted
0
Do you use autocommitted connection?
Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
stu derby
Ranch Hand
Joined: Dec 15, 2005
Posts: 333
posted
0
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
Joined: Feb 17, 2006
Posts: 9
posted
0
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?