Re: Multiple open ResultSets not allowed?
От | Rich Cullingford |
---|---|
Тема | Re: Multiple open ResultSets not allowed? |
Дата | |
Msg-id | 3E760573.8010809@sysd.com обсуждение исходный текст |
Ответ на | idle in transaction ("Alexey Yudichev" <Alexey@francoudi.com>) |
Список | pgsql-jdbc |
Jeff Kolesky wrote: > Just to make sure I wasn't looking at the code incorrectly, I wrote the > following test code, making sure not to close the connection before > trying to get data from the result set: > > Connection con = DB.getConnection(); > Statement s1 = con.createStatement(); > ResultSet rs1 = s1.executeQuery("SELECT * FROM table1"); > while(rs1.next()) > { > String col = rs1.getString("col"); > System.out.println(col); > Statement s2 = con.createStatement(); > ResultSet rs2 = s2.executeQuery("SELECT * FROM table2"); > while(rs2.next()) > { > String col2 = rs2.getString("col"); > System.out.println("\t" + col2); > } > rs2.close(); > s2.close(); > } > rs1.close(); > s1.close(); > con.close(); > > Running this code throws the same exception. Looks like the connection > is being closed incorrectly by the driver, or more likely that ResultSet > data (Vector rows) is being set to null somehow. All, Something definitely seems to be resetting rows to null when a second ResultSet is created on a Connection where another already exists. We see this problem when we request a second rs (differing only by an ORDER BY from the original) in a UI app we have. Inserting an initialization: //don't know how this happens, but... if (rows == null) { rows = new Vector(); } in the code for AbstractJdbc2ResultSet#absolute(int index) cured a null pointer exception, but of course this is completely unsatisfactory. Haven't had a chance to track down where this var gets set yet... Rich Cullingford rculling@sysd.com
В списке pgsql-jdbc по дате отправления: