pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sathyajith G <sathyajith@inbox.com>
To: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: exception while upgrading driver
Date: Tue, 7 Jun 2005 12:05:28 -0800
Message-ID: <970549EC73A.000005A3sathyajith@inbox.com> (raw)
In-Reply-To: <Pine.BSO.4.56.0506071413110.5751@leary.csoft.net>
References: <9648e4d3482.000004d1sathyajith@inbox.com>

>>
>
> 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


view thread (5+ messages)  latest in thread

Message-ID: <970549EC73A.000005A3sathyajith@inbox.com>
Permalink:  ../970549EC73A.000005A3sathyajith@inbox.com/
Also on:    postgresql.org/message-id/970549EC73A.000005A3sathyajith@inbox.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: sathyajith@inbox.com, books@ejurka.com
  Subject: Re: exception while upgrading driver
  In-Reply-To: <970549EC73A.000005A3sathyajith@inbox.com>
  References: <9648e4d3482.000004d1sathyajith@inbox.com> <970549EC73A.000005A3sathyajith@inbox.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox