Received: from localhost (unknown [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D5F179F953B for ; Mon, 3 Sep 2007 08:36:12 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 21075-01 for ; Mon, 3 Sep 2007 08:36: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 550209F936A for ; Mon, 3 Sep 2007 08:36:00 -0300 (ADT) thread-index: AcfuHqHNfjyLIdzFSwuRCZg7FuNv+w== Received: from [172.24.32.90] ([62.232.55.118]) by mail01.enterprisedb.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 3 Sep 2007 07:36:11 -0400 Content-Class: urn:content-classes:message Message-ID: <46DBF161.8050701@enterprisedb.com> Importance: normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.4073 Date: Mon, 03 Sep 2007 12:34:57 +0100 From: "Heikki Linnakangas" User-Agent: Icedove 1.5.0.12 (X11/20070730) MIME-Version: 1.0 To: "Rob Kirkbride" Cc: Subject: Re: Data Migration References: In-Reply-To: Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 03 Sep 2007 11:36:12.0031 (UTC) FILETIME=[A0F6D8F0:01C7EE1E] X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/4 X-Sequence-Number: 17426 Rob Kirkbride wrote: > Is there a way in JDBC to move data from one database to another without > having to hard-wire the table structure? > > I was wondering if I can do a kind of > > ResultSet rs = executeStatement("select * from table (from connection 1) > where somecondition") > while (rs.next()) > take the resultset and then pass directly into a prepared statement for > an "insert into table" (from connection 2) > > I can't see any way other disecting the values from the first query and > using getSQLType. That seems like the easiest solution to me. You can do it completely dynamically with no hard-wired table structure using the metadata. Perhaps you could do it with the JDBC 4 RowSet API? I haven't looked at it in detail. -- Heikki Linnakangas EnterpriseDB http://www.enterprisedb.com