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 7D8C73AC0A5 for ; Tue, 28 Dec 2004 13:08:49 +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 29206-06 for ; Tue, 28 Dec 2004 13:08:33 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 4416E3AC5AC for ; Tue, 28 Dec 2004 13:08:34 +0000 (GMT) Received: (qmail 19598 invoked from network); 28 Dec 2004 13:08:08 -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 13:08:08 -0000 Message-ID: <41D15ACB.8050109@fastcrypt.com> Date: Tue, 28 Dec 2004 08:08:27 -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: pgsql-jdbc@postgresql.org Subject: Re: problem to get nextval of a sequence References: <41D15580.3050700@daniel.schaedler.name> In-Reply-To: <41D15580.3050700@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.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/193 X-Sequence-Number: 11859 Daniel, You have to call ress.next() before you get the value. Dave Daniel Schaedler wrote: > 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. > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkResultSet(AbstractJdbc2ResultSet.java:2380) > > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:1821) > > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getFixedString(AbstractJdbc2ResultSet.java:2326) > > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:1935) > > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.getLong(AbstractJdbc2ResultSet.java:2158) > > at org.daniel.pws.store.PostgresStore.newNode(PostgresStore.java:307) > at org.daniel.pws.store.StoreTester.main(StoreTester.java:71) > 2004-12-28 13:41:57,983 - not able to get the new nodeID > **** > > executing the query in PostgresSQL directly works, I get the correct > return value. > The Query itself seems to be executet, as I get other exceptions if I > misspell the columnname (e.g.). > I'm working with Postgres-jdbc: pg80b1-1.308.jdbc3.jar and JDK 1.5.0 > > someone an Idea? > > wishing all a Happy new Year > Daniel -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561