Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id BB15A9FB513 for ; Wed, 10 Oct 2007 09:55:08 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 21830-07 for ; Wed, 10 Oct 2007 09:55:02 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from mail01.enterprisedb.com (mail01.enterprisedb.com [63.246.7.168]) by postgresql.org (Postfix) with ESMTP id 1155A9FB4C8 for ; Wed, 10 Oct 2007 09:55:01 -0300 (ADT) thread-index: AcgLPM4wxI+yUI4uSLmlMUKGmgo8IA== Received: from [172.24.32.198] ([62.232.55.118]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Wed, 10 Oct 2007 08:55:15 -0400 Message-ID: <470CCB67.80106@enterprisedb.com> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073 Content-class: urn:content-classes:message Importance: normal Date: Wed, 10 Oct 2007 13:53:59 +0100 From: "Heikki Linnakangas" User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: "Christian Rengstl" Cc: Subject: Re: Update ResultSet References: <470CE177.90AD.0080.0@klinik.uni-regensburg.de> In-Reply-To: <470CE177.90AD.0080.0@klinik.uni-regensburg.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-OriginalArrivalTime: 10 Oct 2007 12:55:16.0359 (UTC) FILETIME=[CE169970:01C80B3C] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200710/70 X-Sequence-Number: 17642 Only simple result sets coming from a single table, with no joins, are updateable. Granted, the error message is misleading. The driver has to parse the query, to extract the name of the table to update or throw an error if there's more than one table involved. In this case, it doesn't understand the INNER JOIN, and therefore you get the misleading error message instead of this: "ResultSet is not updateable. The query that generated this result set must select only one table, and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details." Christian Rengstl wrote: > Hi everyone, > > I have a query including an inner join, which I execute to obtain a > ResultSet, but when I execute the following piece of code I get an error > message saying that it could not update the table because it could not > find the primary key for a table. > rs.first(); > rs.updateString("gene", "TestGen"); > rs.updateRow(); > > Here is my query: > SELECT gene_entropy.gene, gene_entropy.entropy, gene_entropy.iteration, > snp_entropy.snp_id > FROM clustering.gene_entropy INNER JOIN clustering.snp_entropy > USING(gene) limit 5; > > And here is the stacktrace: > org.postgresql.util.PSQLException: Für die Tebelle > (clustering.gene_entropy konnte kein Primärschlüssel gefunden werden. > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.isUpdateable(AbstractJdbc2ResultSet.java:1547) > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkUpdateable(AbstractJdbc2ResultSet.java:2550) > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateValue(AbstractJdbc2ResultSet.java:2796) > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateString(AbstractJdbc2ResultSet.java:1309) > at > org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateString(AbstractJdbc2ResultSet.java:1394) > at > myapp.ui.event.DBTableFrameListener.actionPerformed(DBTableFrameListener.java:406) > at > javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) > at > javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) > at > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) > at > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) > at > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) > at > java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272) > at java.awt.Component.processMouseEvent(Component.java:6038) > at > javax.swing.JComponent.processMouseEvent(JComponent.java:3260) > at java.awt.Component.processEvent(Component.java:5803) > at java.awt.Container.processEvent(Container.java:2058) > at java.awt.Component.dispatchEventImpl(Component.java:4410) > at java.awt.Container.dispatchEventImpl(Container.java:2116) > at java.awt.Component.dispatchEvent(Component.java:4240) > at > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) > at > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) > at > java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) > at java.awt.Container.dispatchEventImpl(Container.java:2102) > at java.awt.Window.dispatchEventImpl(Window.java:2429) > at java.awt.Component.dispatchEvent(Component.java:4240) > at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) > at > java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) > at > java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) > at > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) > at > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) > at > java.awt.EventDispatchThread.run(EventDispatchThread.java:121) > > I am more than happy and thankful for any advice! -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com