wood burning stoves 2.0*
The moose likes JDBC and the fly likes Result set not showing the latest data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Result set not showing the latest data" Watch "Result set not showing the latest data" New topic
Author

Result set not showing the latest data

Nikhil Menon
Ranch Hand

Joined: Nov 22, 2004
Posts: 70
Hello,

I have a problem while retrieving the data from a table. The code gives correct result when run for the first time then if the table 'Demo' is changed using the SQL editor the subsequent retrievals give the old data and not the new one.
Can anyone reply where i have got it wrong?. Thanks in advance.

The code is given below...



bijoy bose
Ranch Hand

Joined: Mar 27, 2004
Posts: 32
try doing this, see it if it works:

public void retrieve()
{

ArrayList al = new ArrayList();

//....rest of your code...
bijoy bose
Ranch Hand

Joined: Mar 27, 2004
Posts: 32
i am sorry ...
is not void but "List"
kalpana Kumar
Ranch Hand

Joined: Jul 03, 2003
Posts: 65
Try closing the resultset before closing the connection.
close the connection in the finally block.
Nikhil Menon
Ranch Hand

Joined: Nov 22, 2004
Posts: 70
Hello,
Thank you bijoy bose and kalpana Kumar.

I finally solved the problem. There was no problem in the code as such, but the problem was with my sql plus (for Oracle) which was showing the data as updated even though it has not updated. Infact only that editor showed that data is updated and not the table in reality.
No wonder my code always returned the data which is actually as in the table and not as in the editor. Thank you friends once again for giving suggetions. And as you told closing the connection in the finally block that too after closing the result set is a good way to code.
Thanks a lot.

Nikhil Kanjulli Menon.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Result set not showing the latest data
 
Similar Threads
Slight JTable problem
Making ResultSet unEditable
problem with insert and select
Making ResultSet unEditable
Problem accessing AS/400 database thru' JDBC