Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 83686 invoked from network); 25 Apr 2010 14:38:32 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Apr 2010 14:38:32 -0000 Received: (qmail 64520 invoked by uid 500); 25 Apr 2010 14:38:32 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 64461 invoked by uid 500); 25 Apr 2010 14:38:31 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 64454 invoked by uid 99); 25 Apr 2010 14:38:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 14:38:31 +0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bpendleton.derby@gmail.com designates 209.85.160.44 as permitted sender) Received: from [209.85.160.44] (HELO mail-pw0-f44.google.com) (209.85.160.44) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Apr 2010 14:38:23 +0000 Received: by pwj2 with SMTP id 2so7873247pwj.31 for ; Sun, 25 Apr 2010 07:38:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=dRg0f6rGtrVugWzUnWFNhXFJxZieXr+0vc6kamLfnZ8=; b=wKA+WCK1Y7516v6dfWQcKWwOQTyOO+B/GXCxA6UbNq8EdHtujQ5MsxQRFQighEIcEG EHmsuRbTCzbBtKSpS7scV67CoEMUNsW+PL6ui1dxj3an2pf8xY+OfamJ1kbVgI3hczMf C+bS0tpzdh/442ZGaC4S/puuIVLcdULS7WxmA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=LTbHpmL1cBBGl8DZ0NKI0lcN5GjVPHJolwnexDvY//Z+LMXBNwIwqs9yznAM/jDeVn F0jksVwds4b632ymZz6QBTEqZt8H7WE/4P0HvsSAq6+bsuWG0guug6mY02r17xakE/mr 6jEiTnyUiBMDaK1f1A/FbsvYKTGl8MHt9yMXw= Received: by 10.114.162.24 with SMTP id k24mr186076wae.158.1272206282985; Sun, 25 Apr 2010 07:38:02 -0700 (PDT) Received: from [192.168.0.103] (c-67-170-231-73.hsd1.ca.comcast.net [67.170.231.73]) by mx.google.com with ESMTPS id c14sm11602741waa.1.2010.04.25.07.38.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 25 Apr 2010 07:38:02 -0700 (PDT) Message-ID: <4BD453C7.2040201@gmail.com> Date: Sun, 25 Apr 2010 07:37:59 -0700 From: Bryan Pendleton User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: Derby Discussion Subject: Re: Transfer data between tables that are located in different databases References: <210082.32277.qm@web59503.mail.ac4.yahoo.com> In-Reply-To: <210082.32277.qm@web59503.mail.ac4.yahoo.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit > Could someone give me pointers on how to transfer data between two > tables that are identical in structure, but located in different > databases. This task needs to be accomplished through code. A single program can certainly have multiple databases open. Each java.sql.Connection object is tied to a single database, but you can have several Connection objects, each pointing to a different database, and switch back and forth between them in your program as you need to. If it's a lot of data, you could run the export/import system procedures. Export the data from the source table to a text file, then import it to the target table. If it's a small amount of data, you can open two connections in your program, read the data from the source table, and insert the data into the target table. Depending on how generic your transfer code needs to be, you could simply hard-code the names of columns and their data types in your code. Or, you could use the DatabaseMetaData classes to determine the column names at runtime and write a generic transfer routine. Why don't you post the code you've tried so far, and the problems you've encountered, and the community can then suggest solutions to those problems. thanks, bryan