From nahumcastro@gmail.com Thu Feb 3 22:51:22 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DB0B28B9F83 for ; Thu, 3 Feb 2005 22:51:22 +0000 (GMT) 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 12173-08 for ; Thu, 3 Feb 2005 22:51:18 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.194]) by svr1.postgresql.org (Postfix) with ESMTP id 032808B9F7C for ; Thu, 3 Feb 2005 22:51:19 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 71so404397wra for ; Thu, 03 Feb 2005 14:51:19 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=D2qqLPi/WMnhWj42DFzMwYh00/LnFZvkmwsUV6wtEt/BWyFpJ95Op7XQ43Rqj7jE4wdNQDxOLrLteW5U8qwx8HHm70t7EIHNYpdiAmYBKGyP09vEwVO0vzJkEX2afsFzm0iIy958zoGIAnyr01WATrkKYZQk9zbH8+gakzYKKLU= Received: by 10.54.50.73 with SMTP id x73mr53948wrx; Thu, 03 Feb 2005 14:51:15 -0800 (PST) Received: by 10.54.35.39 with HTTP; Thu, 3 Feb 2005 14:51:14 -0800 (PST) Message-ID: <714bb51a050203145120066735@mail.gmail.com> Date: Thu, 3 Feb 2005 16:51:14 -0600 From: Nahum Castro Reply-To: Nahum Castro To: pgsql-jdbc@postgresql.org Subject: next() error Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200502/18 X-Sequence-Number: 12198 I am using postgresql 8 and the 8 JDBC 3 driver. I get the next error: javax.servlet.ServletException: ResultSet not positioned properly, perhaps you need to call next. This code used to work on postgresql 7.4.6 and 215 JDBC 3 driver=20 Has changed something on the server or on the driver? Thanks for your help. This is the code on a jsp page: ---------------------------------------------------------------------------= ---------- <%@ page contentType=3D"text/html; charset=3Diso-8859-1" language=3D"java" import=3D"java.sql.*" errorPage=3D"" %> <%@ include file=3D"Connections/connPubs.jsp" %> <% String RecordsetPubs1 =3D "1"; if (request.getParameter("au_id") !=3D null)=20 { =09RecordsetPubs1 =3D (String)request.getParameter("au_id"); } %> <% Driver DriverRecordsetPubs1 =3D (Driver)Class.forName(connPubs_DRIVER).newInstance(); Connection ConnRecordsetPubs1 =3D DriverManager.getConnection(connPubs_STRING,connPubs_USERNAME,connPubs_PASS= WORD); PreparedStatement StatementRecordsetPubs1 =3D ConnRecordsetPubs1.prepareStatement("SELECT * FROM public.authors WHERE au_id =3D " + RecordsetPubs1 + ""); ResultSet RecordsetPubs1 =3D StatementRecordsetPubs1.executeQuery(); boolean RecordsetPubs1_isEmpty =3D ! RecordsetPubs1.next(); boolean RecordsetPubs1_hasData =3D ! RecordsetPubs1_isEmpty; Object RecordsetPubs1_data; int RecordsetPubs1_numRows =3D 0; %> Untitled Document
au_id <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("au_id"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
au_lname <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("au_lname"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
au_fname <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("au_fname"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
phone <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("phone"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
address <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("address"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
city <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("city"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
state <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("state"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
zip <%=3D(((RecordsetPubs1_data =3D RecordsetPubs1.getObject("zip"))=3D=3Dnull || RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%>
<% RecordsetPubs1.close(); StatementRecordsetPubs1.close(); ConnRecordsetPubs1.close(); %> ---------------------------------------------------------------------------= ----------- --=20 Nahum Castro Gonz=E1lez Le=F3n, Guanajuato, M=E9xico From oliver@opencloud.com Thu Feb 3 23:05:32 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CC0618B9E7B for ; Thu, 3 Feb 2005 23:05:32 +0000 (GMT) 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 14774-04 for ; Thu, 3 Feb 2005 23:05:21 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 732538B9F18 for ; Thu, 3 Feb 2005 23:05:21 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1Cwq2E-0002UI-00; Fri, 04 Feb 2005 12:05:14 +1300 Message-ID: <4202AE28.2080300@opencloud.com> Date: Fri, 04 Feb 2005 12:05:12 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Nahum Castro Cc: pgsql-jdbc@postgresql.org Subject: Re: next() error References: <714bb51a050203145120066735@mail.gmail.com> In-Reply-To: <714bb51a050203145120066735@mail.gmail.com> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/19 X-Sequence-Number: 12199 Nahum Castro wrote: > javax.servlet.ServletException: ResultSet not positioned properly, > perhaps you need to call next. > Has changed something on the server or on the driver? Newer drivers follow the JDBC specification more strictly. > ResultSet RecordsetPubs1 = StatementRecordsetPubs1.executeQuery(); > boolean RecordsetPubs1_isEmpty = ! RecordsetPubs1.next(); > boolean RecordsetPubs1_hasData = ! RecordsetPubs1_isEmpty; [...] > <%=(((RecordsetPubs1_data = > RecordsetPubs1.getObject("au_id"))==null || > RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%> You appear to be calling ResultSet.getObject() even if ResultSet.next() returned false. You're not allowed to do this -- see the JDBC javadoc. -O From nahumcastro@gmail.com Fri Feb 4 00:35:41 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id B09348B9C34 for ; Fri, 4 Feb 2005 00:35:41 +0000 (GMT) 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 29403-10 for ; Fri, 4 Feb 2005 00:35:34 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.201]) by svr1.postgresql.org (Postfix) with ESMTP id 1EA1E8B9FED for ; Fri, 4 Feb 2005 00:35:36 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 71so419370wra for ; Thu, 03 Feb 2005 16:35:36 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=VlFdTf8BdIcRRSjK6DF5JrLAAcew9u1544FdPK4aHTKR1YoE/0BDOoQn/XHvcJJuAbJwNTd9jQE61bl386bvBhuHCKVHqjKRP1AY97n2S3SL6feXFeHmwx2eQw5n4rIcKmbH4w9N4ti+LPYOJVdT8FLwJil1QbvWEeucIlLmWCI= Received: by 10.54.31.20 with SMTP id e20mr4202wre; Thu, 03 Feb 2005 16:35:35 -0800 (PST) Received: by 10.54.35.39 with HTTP; Thu, 3 Feb 2005 16:35:35 -0800 (PST) Message-ID: <714bb51a0502031635613f6fdb@mail.gmail.com> Date: Thu, 3 Feb 2005 18:35:35 -0600 From: Nahum Castro Reply-To: Nahum Castro To: pgsql-jdbc@postgresql.org Subject: Re: next() error In-Reply-To: <4202AE28.2080300@opencloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable References: <714bb51a050203145120066735@mail.gmail.com> <4202AE28.2080300@opencloud.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.024 tagged_above=0 required=5 tests=RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200502/20 X-Sequence-Number: 12200 On Fri, 04 Feb 2005 12:05:12 +1300, Oliver Jowett wr= ote: > Nahum Castro wrote: >=20 > > javax.servlet.ServletException: ResultSet not positioned properly, > > perhaps you need to call next. >=20 > > Has changed something on the server or on the driver? >=20 > Newer drivers follow the JDBC specification more strictly. >=20 > > ResultSet RecordsetPubs1 =3D StatementRecordsetPubs1.executeQuery(); > > boolean RecordsetPubs1_isEmpty =3D ! RecordsetPubs1.next(); > > boolean RecordsetPubs1_hasData =3D ! RecordsetPubs1_isEmpty; >=20 > [...] >=20 > > <%=3D(((RecordsetPubs1_data =3D > > RecordsetPubs1.getObject("au_id"))=3D=3Dnull || > > RecordsetPubs1.wasNull())?"":RecordsetPubs1_data)%> >=20 > You appear to be calling ResultSet.getObject() even if ResultSet.next() > returned false. You're not allowed to do this -- see the JDBC javadoc. >=20 > -O >=20 Thank you.=20 I solved the problem now. --=20 Nahum Castro Gonz=E1lez Le=F3n, Guanajuato, M=E9xico