KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am confused about the behaviour of a ResultSet that is of type TYPE_SCROLL_SENSITIVE . My understanding of this is: I execute a select query that returns me a result set. I print out the value of a particular column in the first row. I then execute Thread.sleep(10000) , which halts the program for 10 seconds. While the program is sleeping, I manually do an update to the same column in the DB (through the SQL prompt). After 10 seconds, I again print the value of the same column in the first row of the result set. In step 4, I expect the printed column value to be different from the value printed in step 1. But I always get the same value (even if my ResultSet is of type SCROLL_TYPE_SENSITIVE ). Am I misunderstanding something here ? Below is the code I use. private void doStuff() throws Exception { final String query = "select * from suppliers where sup_id=420"; Statement stmt = this.con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(query); rs.next(); System.out.println("City : " + rs.getString("city")); Thread.sleep(10000); // While this executes, I do a manual update ! System.out.println("City : " + rs.getString("city")); }
Tags (comma-separated)
Save Edits
Cancel