Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BE7EB632979 for ; Sun, 26 Jul 2009 17:10:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 59585-03 for ; Sun, 26 Jul 2009 20:10:07 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f222.google.com (mail-bw0-f222.google.com [209.85.218.222]) by mail.postgresql.org (Postfix) with ESMTP id 1074E632932 for ; Sun, 26 Jul 2009 17:10:06 -0300 (ADT) Received: by bwz22 with SMTP id 22so2473401bwz.19 for ; Sun, 26 Jul 2009 13:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=ZVZnaGeZiU1+ezHfRONBR9IDh1Zt8Jn/o5sTmz/0o3c=; b=fyFtZ9KH5caC8UdZYLr4YsgwgNQE6iab8cRN1YEa+i+yp9k0LXv9IDgfVxUSDkmo6n U6biaWdy3dEXDtRvJLLDsAm7mzkSB1YnceHKW5Rw3FxnJl9UIzTYFflXZnPXK4T2OH9v SMZXnDe6ZMQcqGKt2LMKRNBrclaoIhsnXcXyU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=p3SfS/v+JBUEBkxl/6w+53AtOaoIkohsth2vKLZ3SfrwPPEeqVPWwwRp7aNizzchqX 0OD6jDEuHLXX9pRux1rLrs9IMXIjqts8oel1DE7k40e+NsH3oNi6fNvNcZhQg40cWSfb sQiWq27qiv0olQdIFxwtwfOq1nLJi47e/6ltI= MIME-Version: 1.0 Received: by 10.223.120.197 with SMTP id e5mr2329686far.25.1248639005238; Sun, 26 Jul 2009 13:10:05 -0700 (PDT) Date: Sun, 26 Jul 2009 16:10:05 -0400 Message-ID: <194f62550907261310v740cd3f9p8a98fa0a81fcf4f7@mail.gmail.com> Subject: Updateable ResultSet doesn't fetch sequence-generated values From: Clemens Eisserer To: pgsql-jdbc@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=-10 required=5 tests=none X-Spam-Level: X-Archive-Number: 200907/66 X-Sequence-Number: 19834 Hello, I am using a library which is using the JDBCRowSet API, in order to bind a user-interface with a SQL database. The library relies on auto generated primary keys (I am using sequences for this task), however after inserting, the key-column with the server-side generated value is set to 0. I am porting the application from MySQL-5.0 to PostgreSQL-8.3, and MySQL sets the key-column to the value generated by auto_increment. Am I doing something wrong here, or is it a bug? Is that behaviour specified at all? The following code outputs "Hallo has key: 0" although it should output "Hallo has key: 10000". > CREATE TABLE customer (key SERIAL PRIMARY KEY NOT NULL, name VARCHAR(255)); > ALTER SEQUENCE customer_key_seq START WITH 10000; > JdbcRowSet rowset = new JdbcRowSetImpl(instance.ssConnection.getConnection()); > rowset.setType(ResultSet.TYPE_SCROLL_INSENSITIVE); > rowset.setConcurrency(ResultSet.CONCUR_UPDATABLE); > rowset.setCommand("SELECT * FROM customer"); > rowset.execute(); > rowset.moveToInsertRow(); > rowset.updateString("name", "Hello"); > rowset.insertRow(); > System.out.println(rowset.getString("name")+" has key: "+rowset.getInt("key")); Thank you in advance, Clemens