Re: Multiple open ResultSets not allowed?

From: Rich Cullingford <rculling(at)sysd(dot)com>
To: Jeff Kolesky <jeff(at)edusoft(dot)com>
Cc: Barry Lind <blind(at)xythos(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Multiple open ResultSets not allowed?
Date: 2003-03-17 17:27:15
Message-ID: 3E760573.8010809@sysd.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sysd(dot)com

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jeff Kolesky 2003-03-17 18:02:04 Fwd: Re: Multiple open ResultSets not allowed?
Previous Message Jeff Kolesky 2003-03-17 17:01:48 Re: Multiple open ResultSets not allowed?