pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Problems with ResultSet
7+ messages / 5 participants
[nested] [flat]

* Problems with ResultSet
@ 2005-10-28 10:18 Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 10:32 ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 10:47 ` Re: Problems with ResultSet Matthew Lunnon <mlunnon@rwa-net.co.uk>
  0 siblings, 2 replies; 7+ messages in thread

From: Aydın Toprak @ 2005-10-28 10:18 UTC (permalink / raw)
  To: pgsql-jdbc

Hiii,


I have just stuck with a little point of my code which generates "This 
ResultSet is closed." exception ....

here is my stack trace ...
org.postgresql.util.PSQLException: This ResultSet is closed.
org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2ResultSet.java:2444) 

org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1810) 

org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.event.Proposal.frameBuyer_jsp:61) 

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) 
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and 
continues...



I want to return ResultSet from static method (I have never did before, 
I guess I can ..??.) ... I get resultset from my jsp page and want to 
display it ...
so ı wrote this database access staff into another class file to sperate 
them ... anyway..


try
           {
           stmnt = con.prepareStatement(query);   
           stmnt.setInt(1, event_id);
           ps = stmnt.executeQuery();
           stmnt.close();
           connMgr.freeConnection("mypool", con);
           if(ps.next())
            out.append("This is your element :"+ps.getInt("event_id"));
           }

this is the part of the code wich generated that exception...

as a result of my obeservations and try... I can directly point that the 
porblem comes from  this
          if(ps.next())
            out.append("This is your element :"+ps.getInt("event_id"));

part of the code...


but I dont understand why?.... the query is file, P.statement and 
connection is exist ... and also there is an integer coloumn "event_id" 
in table...

is it about the static method or what..? ..

Thanks..



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
@ 2005-10-28 10:32 ` David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 10:56   ` Re: Problems with ResultSet João Paulo Ribeiro <jp@mobicomp.com>
  1 sibling, 1 reply; 7+ messages in thread

From: David Goodenough @ 2005-10-28 10:32 UTC (permalink / raw)
  To: pgsql-jdbc

Closing the statement closes everything that came from it, i.e. the ResultSet.  
So you need to delay closing the statement until after you have finished with
the ResultSet.

David

On Friday 28 October 2005 11:18, Aydın Toprak wrote:
> Hiii,
>
>
> I have just stuck with a little point of my code which generates "This
> ResultSet is closed." exception ....
>
> here is my stack trace ...
> org.postgresql.util.PSQLException: This ResultSet is closed.
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2Result
>Set.java:2444)
>
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.jav
>a:1810)
>
> org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.eve
>nt.Proposal.frameBuyer_jsp:61)
>
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and
> continues...
>
>
>
> I want to return ResultSet from static method (I have never did before,
> I guess I can ..??.) ... I get resultset from my jsp page and want to
> display it ...
> so ı wrote this database access staff into another class file to sperate
> them ... anyway..
>
>
> try
>            {
>            stmnt = con.prepareStatement(query);
>            stmnt.setInt(1, event_id);
>            ps = stmnt.executeQuery();
>            stmnt.close();
>            connMgr.freeConnection("mypool", con);
>            if(ps.next())
>             out.append("This is your element :"+ps.getInt("event_id"));
>            }
>
> this is the part of the code wich generated that exception...
>
> as a result of my obeservations and try... I can directly point that the
> porblem comes from  this
>           if(ps.next())
>             out.append("This is your element :"+ps.getInt("event_id"));
>
> part of the code...
>
>
> but I dont understand why?.... the query is file, P.statement and
> connection is exist ... and also there is an integer coloumn "event_id"
> in table...
>
> is it about the static method or what..? ..
>
> Thanks..
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 10:32 ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
@ 2005-10-28 10:56   ` João Paulo Ribeiro <jp@mobicomp.com>
  2005-10-28 12:38     ` Re: Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
  0 siblings, 1 reply; 7+ messages in thread

From: João Paulo Ribeiro @ 2005-10-28 10:56 UTC (permalink / raw)
  To: David Goodenough <david.goodenough@btconnect.com>; +Cc: pgsql-jdbc

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
David is rigth. <br>
And try to avoid returning resultset. If your method need to return
something do it with your own objects.<br>
Do something like:<br>
<br>
-&gt; get connection<br>
-&gt; create statement on the connection<br>
-&gt; execute statement and get resultset<br>
-&gt; iterate resultset and create your own object with the information
needed<br>
-&gt; close statement<br>
-&gt; return the object you created with the information from the
resultset<br>
<br>
Note:  if your using a pool always release the connection to the pool. <br>
<br>
<br>
Regards.<br>
João Paulo Ribeiro<br>
<br>
<br>
David Goodenough wrote:
<blockquote cite="mid200510281132.29818.david.goodenough@btconnect.com"
 type="cite">
  <pre wrap="">Closing the statement closes everything that came from it, i.e. the ResultSet.  
So you need to delay closing the statement until after you have finished with
the ResultSet.

David

On Friday 28 October 2005 11:18, Aydın Toprak wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Hiii,


I have just stuck with a little point of my code which generates "This
ResultSet is closed." exception ....

here is my stack trace ...
org.postgresql.util.PSQLException: This ResultSet is closed.
org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2Result
Set.java:2444)

org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.jav
a:1810)

org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.eve
nt.Proposal.frameBuyer_jsp:61)

org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and
continues...



I want to return ResultSet from static method (I have never did before,
I guess I can ..??.) ... I get resultset from my jsp page and want to
display it ...
so ı wrote this database access staff into another class file to sperate
them ... anyway..


try
           {
           stmnt = con.prepareStatement(query);
           stmnt.setInt(1, event_id);
           ps = stmnt.executeQuery();
           stmnt.close();
           connMgr.freeConnection("mypool", con);
           if(ps.next())
            out.append("This is your element :"+ps.getInt("event_id"));
           }

this is the part of the code wich generated that exception...

as a result of my obeservations and try... I can directly point that the
porblem comes from  this
          if(ps.next())
            out.append("This is your element :"+ps.getInt("event_id"));

part of the code...


but I dont understand why?.... the query is file, P.statement and
connection is exist ... and also there is an integer coloumn "event_id"
in table...

is it about the static method or what..? ..

Thanks..

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
    </pre>
  </blockquote>
  <pre wrap=""><!---->
---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to <a class="moz-txt-link-abbreviated" href="mailto:majordomo@postgresql.org">majordomo@postgresql.org</a> so that your
       message can get through to the mailing list cleanly


  </pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
João Paulo Ribeiro | Senior Software Engineer
<a class="moz-txt-link-abbreviated" href="mailto:jp@mobicomp.com">jp@mobicomp.com</a>

PHONE: + 351 253 305 250
FAX  : + 351 253 305 250
<a class="moz-txt-link-abbreviated" href="http://www.mobicomp.com">www.mobicomp.com</a;

________________________________________________________________

About Solutions | Wireless World

CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.
DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.</pre>
</body>
</html>



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 10:32 ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 10:56   ` Re: Problems with ResultSet João Paulo Ribeiro <jp@mobicomp.com>
@ 2005-10-28 12:38     ` Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 13:03       ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 14:22       ` Re: Problems with ResultSet Ken Geis <kgeis@speakeasy.net>
  0 siblings, 2 replies; 7+ messages in thread

From: Aydın Toprak @ 2005-10-28 12:38 UTC (permalink / raw)
  To: pgsql-jdbc


Ok you are right, that works... however I really dont understand why it 
fails...
I though that I get all the results in my ResultSet obeject and keep it 
safe , distant  from closing connections or statements...

as for returning my objects,
I want all the result set .. so that I think,in these circumstances, 
there is no need to  generate my own objects and add them to the 
returning vector...

am I mising a point?





João Paulo Ribeiro wrote:

> David is rigth.
> And try to avoid returning resultset. If your method need to return 
> something do it with your own objects.
> Do something like:
>
> -> get connection
> -> create statement on the connection
> -> execute statement and get resultset
> -> iterate resultset and create your own object with the information 
> needed
> -> close statement
> -> return the object you created with the information from the resultset
>
> Note:  if your using a pool always release the connection to the pool.
>
>
> Regards.
> João Paulo Ribeiro
>
>
> David Goodenough wrote:
>
>>Closing the statement closes everything that came from it, i.e. the ResultSet.  
>>So you need to delay closing the statement until after you have finished with
>>the ResultSet.
>>
>>David
>>
>>On Friday 28 October 2005 11:18, Aydın Toprak wrote:
>>  
>>
>>>Hiii,
>>>
>>>
>>>I have just stuck with a little point of my code which generates "This
>>>ResultSet is closed." exception ....
>>>
>>>here is my stack trace ...
>>>org.postgresql.util.PSQLException: This ResultSet is closed.
>>>org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2Result
>>>Set.java:2444)
>>>
>>>org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.jav
>>>a:1810)
>>>
>>>org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.eve
>>>nt.Proposal.frameBuyer_jsp:61)
>>>
>>>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>>javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and
>>>continues...
>>>
>>>
>>>
>>>I want to return ResultSet from static method (I have never did before,
>>>I guess I can ..??.) ... I get resultset from my jsp page and want to
>>>display it ...
>>>so ı wrote this database access staff into another class file to sperate
>>>them ... anyway..
>>>
>>>
>>>try
>>>           {
>>>           stmnt = con.prepareStatement(query);
>>>           stmnt.setInt(1, event_id);
>>>           ps = stmnt.executeQuery();
>>>           stmnt.close();
>>>           connMgr.freeConnection("mypool", con);
>>>           if(ps.next())
>>>            out.append("This is your element :"+ps.getInt("event_id"));
>>>           }
>>>
>>>this is the part of the code wich generated that exception...
>>>
>>>as a result of my obeservations and try... I can directly point that the
>>>porblem comes from  this
>>>          if(ps.next())
>>>            out.append("This is your element :"+ps.getInt("event_id"));
>>>
>>>part of the code...
>>>
>>>
>>>but I dont understand why?.... the query is file, P.statement and
>>>connection is exist ... and also there is an integer coloumn "event_id"
>>>in table...
>>>
>>>is it about the static method or what..? ..
>>>
>>>Thanks..
>>>
>>>---------------------------(end of broadcast)---------------------------
>>>TIP 2: Don't 'kill -9' the postmaster
>>>    
>>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 1: if posting/reading through Usenet, please send an appropriate
>>       subscribe-nomail command to majordomo@postgresql.org so that your
>>       message can get through to the mailing list cleanly
>>
>>
>>  
>>
>
>
>-- 
>João Paulo Ribeiro | Senior Software Engineer
>jp@mobicomp.com
>
>PHONE: + 351 253 305 250
>FAX  : + 351 253 305 250
>www.mobicomp.com
>
>________________________________________________________________
>
>About Solutions | Wireless World
>
>CONFIDENTIALITY NOTICE: This message, as well as existing attached files, is confidential and intended exclusively for the individual(s) named as addressees. If you are not the intended recipient, you are kindly requested not to make any use whatsoever of its contents and to proceed to the destruction of the message, thereby notifying the sender.
>DISCLAIMER: The sender of this message can not ensure the security of its electronic transmission and consequently does not accept liability for any fact which may interfere with the integrity of its content.
>




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 10:32 ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 10:56   ` Re: Problems with ResultSet João Paulo Ribeiro <jp@mobicomp.com>
  2005-10-28 12:38     ` Re: Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
@ 2005-10-28 13:03       ` David Goodenough <david.goodenough@btconnect.com>
  1 sibling, 0 replies; 7+ messages in thread

From: David Goodenough @ 2005-10-28 13:03 UTC (permalink / raw)
  To: pgsql-jdbc

Unfortunately for you it is part of the JDBC spec that when you close the
statement things like ResultSets which came from the statement get closed
automatically.

David 

On Friday 28 October 2005 13:38, Aydın Toprak wrote:
> Ok you are right, that works... however I really dont understand why it
> fails...
> I though that I get all the results in my ResultSet obeject and keep it
> safe , distant  from closing connections or statements...
>
> as for returning my objects,
> I want all the result set .. so that I think,in these circumstances,
> there is no need to  generate my own objects and add them to the
> returning vector...
>
> am I mising a point?
>
> João Paulo Ribeiro wrote:
> > David is rigth.
> > And try to avoid returning resultset. If your method need to return
> > something do it with your own objects.
> > Do something like:
> >
> > -> get connection
> > -> create statement on the connection
> > -> execute statement and get resultset
> > -> iterate resultset and create your own object with the information
> > needed
> > -> close statement
> > -> return the object you created with the information from the resultset
> >
> > Note:  if your using a pool always release the connection to the pool.
> >
> >
> > Regards.
> > João Paulo Ribeiro
> >
> > David Goodenough wrote:
> >>Closing the statement closes everything that came from it, i.e. the
> >> ResultSet. So you need to delay closing the statement until after you
> >> have finished with the ResultSet.
> >>
> >>David
> >>
> >>On Friday 28 October 2005 11:18, Aydın Toprak wrote:
> >>>Hiii,
> >>>
> >>>
> >>>I have just stuck with a little point of my code which generates "This
> >>>ResultSet is closed." exception ....
> >>>
> >>>here is my stack trace ...
> >>>org.postgresql.util.PSQLException: This ResultSet is closed.
> >>>org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2Res
> >>>ult Set.java:2444)
> >>>
> >>>org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.
> >>>jav a:1810)
> >>>
> >>>org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.
> >>>eve nt.Proposal.frameBuyer_jsp:61)
> >>>
> >>>org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
> >>>javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and
> >>>continues...
> >>>
> >>>
> >>>
> >>>I want to return ResultSet from static method (I have never did before,
> >>>I guess I can ..??.) ... I get resultset from my jsp page and want to
> >>>display it ...
> >>>so ı wrote this database access staff into another class file to sperate
> >>>them ... anyway..
> >>>
> >>>
> >>>try
> >>>           {
> >>>           stmnt = con.prepareStatement(query);
> >>>           stmnt.setInt(1, event_id);
> >>>           ps = stmnt.executeQuery();
> >>>           stmnt.close();
> >>>           connMgr.freeConnection("mypool", con);
> >>>           if(ps.next())
> >>>            out.append("This is your element :"+ps.getInt("event_id"));
> >>>           }
> >>>
> >>>this is the part of the code wich generated that exception...
> >>>
> >>>as a result of my obeservations and try... I can directly point that the
> >>>porblem comes from  this
> >>>          if(ps.next())
> >>>            out.append("This is your element :"+ps.getInt("event_id"));
> >>>
> >>>part of the code...
> >>>
> >>>
> >>>but I dont understand why?.... the query is file, P.statement and
> >>>connection is exist ... and also there is an integer coloumn "event_id"
> >>>in table...
> >>>
> >>>is it about the static method or what..? ..
> >>>
> >>>Thanks..
> >>>
> >>>---------------------------(end of broadcast)---------------------------
> >>>TIP 2: Don't 'kill -9' the postmaster
> >>
> >>---------------------------(end of broadcast)---------------------------
> >>TIP 1: if posting/reading through Usenet, please send an appropriate
> >>       subscribe-nomail command to majordomo@postgresql.org so that your
> >>       message can get through to the mailing list cleanly
> >
> >--
> >João Paulo Ribeiro | Senior Software Engineer
> >jp@mobicomp.com
> >
> >PHONE: + 351 253 305 250
> >FAX  : + 351 253 305 250
> >www.mobicomp.com
> >
> >________________________________________________________________
> >
> >About Solutions | Wireless World
> >
> >CONFIDENTIALITY NOTICE: This message, as well as existing attached files,
> > is confidential and intended exclusively for the individual(s) named as
> > addressees. If you are not the intended recipient, you are kindly
> > requested not to make any use whatsoever of its contents and to proceed
> > to the destruction of the message, thereby notifying the sender.
> > DISCLAIMER: The sender of this message can not ensure the security of its
> > electronic transmission and consequently does not accept liability for
> > any fact which may interfere with the integrity of its content.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
  2005-10-28 10:32 ` Re: Problems with ResultSet David Goodenough <david.goodenough@btconnect.com>
  2005-10-28 10:56   ` Re: Problems with ResultSet João Paulo Ribeiro <jp@mobicomp.com>
  2005-10-28 12:38     ` Re: Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
@ 2005-10-28 14:22       ` Ken Geis <kgeis@speakeasy.net>
  1 sibling, 0 replies; 7+ messages in thread

From: Ken Geis @ 2005-10-28 14:22 UTC (permalink / raw)
  To: pgsql-jdbc; Aydõn Toprak <aydin.toprak@intengo.com>

CachedRowSet does what you want to do.  There's a good explanation here:

http://www.onjava.com/pub/a/onjava/2004/06/23/cachedrowset.html


Ken

On Oct 28, 2005, at 5:38 AM, Aydõn Toprak wrote:
>
> Ok you are right, that works... however I really dont understand why  
> it fails...
> I though that I get all the results in my ResultSet obeject and keep  
> it safe , distant  from closing connections or statements...
>
> as for returning my objects,
> I want all the result set .. so that I think,in these circumstances,  
> there is no need to  generate my own objects and add them to the  
> returning vector...
>
> am I mising a point?
>
>
>
>
>
> Jo‹o Paulo Ribeiro wrote:
>
>> David is rigth.
>> And try to avoid returning resultset. If your method need to return  
>> something do it with your own objects.
>> Do something like:
>>
>> -> get connection
>> -> create statement on the connection
>> -> execute statement and get resultset
>> -> iterate resultset and create your own object with the information  
>> needed
>> -> close statement
>> -> return the object you created with the information from the  
>> resultset
>>
>> Note:  if your using a pool always release the connection to the pool.
>>
>>
>> Regards.
>> Jo‹o Paulo Ribeiro
>>
>>
>> David Goodenough wrote:
>>
>>> Closing the statement closes everything that came from it, i.e. the  
>>> ResultSet.  So you need to delay closing the statement until after  
>>> you have finished with
>>> the ResultSet.
>>>
>>> David
>>>
>>> On Friday 28 October 2005 11:18, Aydõn Toprak wrote:
>>>
>>>> Hiii,
>>>>
>>>>
>>>> I have just stuck with a little point of my code which generates  
>>>> "This
>>>> ResultSet is closed." exception ....
>>>>
>>>> here is my stack trace ...
>>>> org.postgresql.util.PSQLException: This ResultSet is closed.
>>>> org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc 
>>>> 2Result
>>>> Set.java:2444)
>>>>
>>>> org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2Result 
>>>> Set.jav
>>>> a:1810)
>>>>
>>>> org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache. 
>>>> jsp.eve
>>>> nt.Proposal.frameBuyer_jsp:61)
>>>>
>>>> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
>>>> javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and
>>>> continues...
>>>>
>>>>
>>>>
>>>> I want to return ResultSet from static method (I have never did  
>>>> before,
>>>> I guess I can ..??.) ... I get resultset from my jsp page and want  
>>>> to
>>>> display it ...
>>>> so õ wrote this database access staff into another class file to  
>>>> sperate
>>>> them ... anyway..
>>>>
>>>>
>>>> try
>>>>           {
>>>>           stmnt = con.prepareStatement(query);
>>>>           stmnt.setInt(1, event_id);
>>>>           ps = stmnt.executeQuery();
>>>>           stmnt.close();
>>>>           connMgr.freeConnection("mypool", con);
>>>>           if(ps.next())
>>>>            out.append("This is your element  
>>>> :"+ps.getInt("event_id"));
>>>>           }
>>>>
>>>> this is the part of the code wich generated that exception...
>>>>
>>>> as a result of my obeservations and try... I can directly point  
>>>> that the
>>>> porblem comes from  this
>>>>          if(ps.next())
>>>>            out.append("This is your element  
>>>> :"+ps.getInt("event_id"));
>>>>
>>>> part of the code...
>>>>
>>>>
>>>> but I dont understand why?.... the query is file, P.statement and
>>>> connection is exist ... and also there is an integer coloumn  
>>>> "event_id"
>>>> in table...
>>>>
>>>> is it about the static method or what..? ..
>>>>
>>>> Thanks..
>>>>
>>>> ---------------------------(end of  
>>>> broadcast)---------------------------
>>>> TIP 2: Don't 'kill -9' the postmaster
>>>>
>>>
>>> ---------------------------(end of  
>>> broadcast)---------------------------
>>> TIP 1: if posting/reading through Usenet, please send an appropriate
>>>       subscribe-nomail command to majordomo@postgresql.org so that  
>>> your
>>>       message can get through to the mailing list cleanly
>>>
>>>
>>>
>>
>>
>> -- 
>> Jo‹o Paulo Ribeiro | Senior Software Engineer
>> jp@mobicomp.com
>>
>> PHONE: + 351 253 305 250
>> FAX  : + 351 253 305 250
>> www.mobicomp.com
>>
>> ________________________________________________________________
>>
>> About Solutions | Wireless World
>>
>> CONFIDENTIALITY NOTICE: This message, as well as existing attached  
>> files, is confidential and intended exclusively for the individual(s)  
>> named as addressees. If you are not the intended recipient, you are  
>> kindly requested not to make any use whatsoever of its contents and  
>> to proceed to the destruction of the message, thereby notifying the  
>> sender.
>> DISCLAIMER: The sender of this message can not ensure the security of  
>> its electronic transmission and consequently does not accept  
>> liability for any fact which may interfere with the integrity of its  
>> content.
>>
>
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 6: explain analyze is your friend




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Problems with ResultSet
  2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
@ 2005-10-28 10:47 ` Matthew Lunnon <mlunnon@rwa-net.co.uk>
  1 sibling, 0 replies; 7+ messages in thread

From: Matthew Lunnon @ 2005-10-28 10:47 UTC (permalink / raw)
  To: Aydın Toprak <aydin.toprak@intengo.com>; +Cc: pgsql-jdbc

Its the stmnt.close() that is the problem.  This will close the 
ResultSet as well.  You will need to close this statement at some point 
but you must use the ResultSet first.  Come possiblility is to return 
the statement and not the result set.  You can then call getResultSet() 
on the statement and close the statement when you are finished.

You should also make sure that you tidy up the connection.

Cheers
Matthew.

Aydın Toprak wrote:

> Hiii,
>
>
> I have just stuck with a little point of my code which generates "This 
> ResultSet is closed." exception ....
>
> here is my stack trace ...
> org.postgresql.util.PSQLException: This ResultSet is closed.
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2ResultSet.java:2444) 
>
> org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1810) 
>
> org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.jsp.event.Proposal.frameBuyer_jsp:61) 
>
> org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) 
> javax.servlet.http.HttpServlet.service(HttpServlet.java:802) ... and 
> continues...
>
>
>
> I want to return ResultSet from static method (I have never did 
> before, I guess I can ..??.) ... I get resultset from my jsp page and 
> want to display it ...
> so ı wrote this database access staff into another class file to 
> sperate them ... anyway..
>
>
> try
>           {
>           stmnt = con.prepareStatement(query);             
> stmnt.setInt(1, event_id);
>           ps = stmnt.executeQuery();
>           stmnt.close();
>           connMgr.freeConnection("mypool", con);
>           if(ps.next())
>            out.append("This is your element :"+ps.getInt("event_id"));
>           }
>
> this is the part of the code wich generated that exception...
>
> as a result of my obeservations and try... I can directly point that 
> the porblem comes from  this
>          if(ps.next())
>            out.append("This is your element :"+ps.getInt("event_id"));
>
> part of the code...
>
>
> but I dont understand why?.... the query is file, P.statement and 
> connection is exist ... and also there is an integer coloumn 
> "event_id" in table...
>
> is it about the static method or what..? ..
>
> Thanks..
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
> _____________________________________________________________________
> This e-mail has been scanned for viruses by MCI's Internet Managed 
> Scanning Services - powered by MessageLabs. For further information 
> visit http://www.mci.com




^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-10-28 14:22 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-28 10:18 Problems with ResultSet Aydın Toprak <aydin.toprak@intengo.com>
2005-10-28 10:32 ` David Goodenough <david.goodenough@btconnect.com>
2005-10-28 10:56   ` João Paulo Ribeiro <jp@mobicomp.com>
2005-10-28 12:38     ` Aydın Toprak <aydin.toprak@intengo.com>
2005-10-28 13:03       ` David Goodenough <david.goodenough@btconnect.com>
2005-10-28 14:22       ` Ken Geis <kgeis@speakeasy.net>
2005-10-28 10:47 ` Matthew Lunnon <mlunnon@rwa-net.co.uk>

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