From: | Sathyajith G <sathyajith(at)inbox(dot)com> |
---|---|
To: | Kris Jurka <books(at)ejurka(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: exception while upgrading driver |
Date: | 2005-06-07 20:05:28 |
Message-ID: | 970549EC73A.000005A3sathyajith@inbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
>>
>
> On Tue, 7 Jun 2005, Sathyajith G wrote:
>
> > i have the following code running without any errors with postgres
> 7.4.2.
> > driver.
> >
> > String qry="select ...;
> >
> > try{
> > ResultSet rs=Data.getResultSet(qry);
> > while(rs.next())
> >
> > I changed the driver to postgres 8.0.1. Strangely now, the above code
> gives
> > the exception "The resultset is closed". Please help.
> >
>
> I suspect your Data.getResultSet() method looks something like this:
>
>
> Statement stmt = conn.createStatement();
> ResultSet rs = stmt.executeQuery(sql);
> stmt.close();
> return rs;
>
> This is not a legal thing to do, closing the Statement also closes the
> ResultSet that was created by it. The 7.4 driver did not correctly check
> this, but the 8.0 version does. You most postpone the Statement close
> until you are done with the ResultSet.
>
> Kris Jurka
>
-------------------------------------------------------------------
i am not closing the statement anywhere. this is how Data.getResultSet()
looks like:
public static ResultSet getResultSet(String sql)
{
ResultSet rs;
try{
rs=stmt.executeQuery(sql);
}catch(Exception e)
{System.err.println("error");
rs=null;
}
return rs;
}
Sathyajith Gopi
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2005-06-07 21:38:34 | Re: DatabaseMetaData and Transactions |
Previous Message | Fernando Hartmann | 2005-06-07 19:41:13 | Num of returned ROWS |