X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A74F1D83C3 for ; Fri, 28 Oct 2005 11:22:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 59544-07 for ; Fri, 28 Oct 2005 14:22:10 +0000 (GMT) Received: from mail24.sea5.speakeasy.net (mail24.sea5.speakeasy.net [69.17.117.26]) by svr1.postgresql.org (Postfix) with ESMTP id 4FFC3DB1FC for ; Fri, 28 Oct 2005 11:22:12 -0300 (ADT) Received: (qmail 8763 invoked from network); 28 Oct 2005 14:22:16 -0000 Received: from dsl081-050-168.sfo1.dsl.speakeasy.net (HELO [192.168.1.102]) (kgeis@[64.81.50.168]) (envelope-sender ) by mail24.sea5.speakeasy.net (qmail-ldap-1.03) with RC4-SHA encrypted SMTP for ; 28 Oct 2005 14:22:16 -0000 Mime-Version: 1.0 (Apple Message framework v623) In-Reply-To: <43621BB5.9050308@intengo.com> References: <4361FAE1.4010806@intengo.com> <200510281132.29818.david.goodenough@btconnect.com> <436203DD.7070000@mobicomp.com> <43621BB5.9050308@intengo.com> Content-Type: text/plain; charset=MACINTOSH; delsp=yes; format=flowed Message-Id: <5d7d229cd5bd8c2cb904161933c98349@speakeasy.net> Content-Transfer-Encoding: quoted-printable From: Ken Geis Subject: Re: Problems with ResultSet Date: Fri, 28 Oct 2005 07:22:15 -0700 To: pgsql-jdbc@postgresql.org, =?MACINTOSH?Q?Ayd=F5n_Toprak?= X-Mailer: Apple Mail (2.623) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.244 required=5 tests=[AWL=0.244] X-Spam-Score: 0.244 X-Spam-Level: X-Archive-Number: 200510/148 X-Sequence-Number: 14079 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=F5n Toprak wrote: > > Ok you are right, that works... however I really dont understand why =20= > it fails... > I though that I get all the results in my ResultSet obeject and keep =20= > 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, =20= > there is no need to generate my own objects and add them to the =20 > returning vector... > > am I mising a point? > > > > > > Jo=8Bo Paulo Ribeiro wrote: > >> David is rigth. >> And try to avoid returning resultset. If your method need to return =20= >> 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 =20= >> needed >> -> close statement >> -> return the object you created with the information from the =20 >> resultset >> >> Note: if your using a pool always release the connection to the = pool. >> >> >> Regards. >> Jo=8Bo Paulo Ribeiro >> >> >> David Goodenough wrote: >> >>> Closing the statement closes everything that came from it, i.e. the =20= >>> ResultSet. So you need to delay closing the statement until after =20= >>> you have finished with >>> the ResultSet. >>> >>> David >>> >>> On Friday 28 October 2005 11:18, Ayd=F5n Toprak wrote: >>> >>>> Hiii, >>>> >>>> >>>> I have just stuck with a little point of my code which generates =20= >>>> "This >>>> ResultSet is closed." exception .... >>>> >>>> here is my stack trace ... >>>> org.postgresql.util.PSQLException: This ResultSet is closed. >>>> = org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc=20 >>>> 2Result >>>> Set.java:2444) >>>> >>>> = org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2Result=20 >>>> Set.jav >>>> a:1810) >>>> >>>> = org.apache.jsp.event.Proposal.frameBuyer_jsp._jspService(org.apache.=20 >>>> 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 =20 >>>> before, >>>> I guess I can ..??.) ... I get resultset from my jsp page and want =20= >>>> to >>>> display it ... >>>> so =F5 wrote this database access staff into another class file to =20= >>>> sperate >>>> them ... anyway.. >>>> >>>> >>>> try >>>> { >>>> stmnt =3D con.prepareStatement(query); >>>> stmnt.setInt(1, event_id); >>>> ps =3D stmnt.executeQuery(); >>>> stmnt.close(); >>>> connMgr.freeConnection("mypool", con); >>>> if(ps.next()) >>>> out.append("This is your element =20 >>>> :"+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 =20 >>>> that the >>>> porblem comes from this >>>> if(ps.next()) >>>> out.append("This is your element =20 >>>> :"+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 =20 >>>> "event_id" >>>> in table... >>>> >>>> is it about the static method or what..? .. >>>> >>>> Thanks.. >>>> >>>> ---------------------------(end of =20 >>>> broadcast)--------------------------- >>>> TIP 2: Don't 'kill -9' the postmaster >>>> >>> >>> ---------------------------(end of =20 >>> broadcast)--------------------------- >>> TIP 1: if posting/reading through Usenet, please send an appropriate >>> subscribe-nomail command to majordomo@postgresql.org so that =20= >>> your >>> message can get through to the mailing list cleanly >>> >>> >>> >> >> >> --=20 >> Jo=8Bo 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 =20= >> files, is confidential and intended exclusively for the individual(s) = =20 >> named as addressees. If you are not the intended recipient, you are =20= >> kindly requested not to make any use whatsoever of its contents and =20= >> to proceed to the destruction of the message, thereby notifying the =20= >> sender. >> DISCLAIMER: The sender of this message can not ensure the security of = =20 >> its electronic transmission and consequently does not accept =20 >> liability for any fact which may interfere with the integrity of its =20= >> content. >> > > > ---------------------------(end of =20 > broadcast)--------------------------- > TIP 6: explain analyze is your friend