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 3BA9D3AC064 for ; Tue, 28 Dec 2004 14:06:00 +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 53652-01 for ; Tue, 28 Dec 2004 14:05:38 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id B064B3AC363 for ; Tue, 28 Dec 2004 14:05:41 +0000 (GMT) Received: (qmail 19844 invoked from network); 28 Dec 2004 14:05:16 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 28 Dec 2004 14:05:16 -0000 Message-ID: <41D16830.7000800@fastcrypt.com> Date: Tue, 28 Dec 2004 09:05:36 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Schaedler Cc: Guillaume Cottenceau , pgsql-jdbc@postgresql.org Subject: Re: problem to get nextval of a sequence References: <41D15580.3050700@daniel.schaedler.name> <87zmzyblx3.fsf@meuh.mnc.ch> <41D1608B.10109@daniel.schaedler.name> In-Reply-To: <41D1608B.10109@daniel.schaedler.name> 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.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/198 X-Sequence-Number: 11864 Daniel, The spec says that you must call next to position the cursor. What happens if nothing comes back? ie an empty result set ? Dave Daniel Schaedler wrote: > Guillaume Cottenceau wrote: > >> Daniel Schaedler writes: >> >> >>> Hi List >>> >>> I try to get the 'nextval' of a sequence: >>> *** >>> String query = "SELECT nextval('nodes_nodeid_seq')"; >>> pstmt = conn.prepareStatement(query); >>> logger.debug("statement: " + pstmt.toString()); >>> ResultSet ress = pstmt.executeQuery(); >>> long newID = ress.getLong("nextval"); // <-- Exception >>> *** >>> >>> I get the following Exception: >>> *** >>> org.postgresql.util.PSQLException: ResultSet not positioned properly, >>> perhaps you need to call next. >> >> >> >> "perhaps you need to call next". >> >> Have you tried calling next? > > > uhhh.... > ....now yes...and it works. > > When I expect only one set of data, I never call next. That's why I > ignored the statement. > > thanks anyway. > Daniel > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561