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 B644A3AC13F for ; Tue, 28 Dec 2004 13:18:50 +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 32828-08 for ; Tue, 28 Dec 2004 13:18:36 +0000 (GMT) Received: from mnc.ch (unknown [212.23.250.43]) by svr1.postgresql.org (Postfix) with ESMTP id 9EC263AC495 for ; Tue, 28 Dec 2004 13:18:38 +0000 (GMT) Received: (qmail 24893 invoked from network); 28 Dec 2004 14:18:37 +0100 Received: from 62-2-77-204.business.cablecom.ch (HELO meuh.mnc.ch) (62.2.77.204) by www.mnc.ch.com with SMTP; 28 Dec 2004 14:18:37 +0100 Received: by meuh.mnc.ch (Postfix, from userid 1000) id EAB0A23F117; Tue, 28 Dec 2004 14:19:04 +0100 (CET) To: Daniel Schaedler Cc: pgsql-jdbc@postgresql.org Subject: Re: problem to get nextval of a sequence References: <41D15580.3050700@daniel.schaedler.name> From: Guillaume Cottenceau Date: 28 Dec 2004 14:19:04 +0100 In-Reply-To: <41D15580.3050700@daniel.schaedler.name> Message-ID: <87zmzyblx3.fsf@meuh.mnc.ch> Lines: 24 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.069 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200412/195 X-Sequence-Number: 11861 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? -- Guillaume Cottenceau