Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#6 Transfer-tool: allow automatic table transfers without GUI

open
nobody
None
5
2014-05-04
2003-03-07
Meikel Bisping
No

The transfer tool was originally designed to always show
a GUI.
I wanted to be able to transfer tables from another
database (Informix) on a regular basis, so I added a
patch for autotransferring to the Transfer tool.
(based on 1.7.0 version - changes in
org.hsqldb.util.Transfer and org.hsqldb.util.TransferTable
marked by START PATCH AUTOTRANSFER / END
PATCH AUTOTRANSFER)

There are two ways to run an autotransfer.
1.
Start from the commandline with a properties-file

java org.hsqldb.util.Transfer -at sample.properties or --
automatictransfer sample.properties

The properties-file has to contain the information about
source and target DB and tables to be transferred
* For example
*source-driver=org.hsqldb.jdbcDriver
*source-url=jdbc:hsqldb:testdb1
*source-username=sa
*source-password=
*target-driver=org.hsqldb.jdbcDriver
*target-url=jdbc:hsqldb:testdb2
*target-username=sa
*target-password=
*table1=testtable
*table2=anotherTesttable
*...

there's a sampletransfer.bat along with a
sample.properties and a test HSQL database (testdb1)
to try it out.
The tables are transferred to testdb2 which is
automatically created by HSQL.

or

2.
run autotransfer from another java file using
either
org.hsqldb.util.Transfer transfer=new
org.hsqldb.util.Transfer();
transfer.autoTransfer(String propFilename);
or
org.hsqldb.util.Transfer transfer=new
org.hsqldb.util.Transfer();
transfer.autoTransfer(String sourceDriver,String
sourceUrl,String sourceUsername,String
sourcePasswd,String targetDriver,String targetUrl,String
targetUsername,String targetPasswd,Vector
desiredTables)
where the last parameter is a Vector containing the
names of the tables, which are to be transferred.

I also added SampleTransfer.java which uses the
methods and can create a backup of HSQL-standalone
databases.
If an exception occurs during the transfer, the original
state is restored from that backup.

Finally, TestTransfer.java (org/test) is a JUnit TestCase
which tests an autotransfer between two HSQL
standlone databases.

I've tested it with Informix and Hsql databases, but it of
course would be good if the developers had a look at it.

Discussion

  • Meikel Bisping
    Meikel Bisping
    2003-03-07

    archive containing all mentioned files

     
  • Fred Toussi
    Fred Toussi
    2003-03-08

    • assigned_to: nobody --> fredt
     
  • Fred Toussi
    Fred Toussi
    2003-03-08

    Logged In: YES
    user_id=150940

    Thanks Meikel,

    It looks like a good idea. Would you be able to update it for the
    version 1.7.1 of Transfer tool?

     
  • Meikel Bisping
    Meikel Bisping
    2003-03-09

    Logged In: YES
    user_id=599625

    I'll transfer it to 1.7.1. I don't know if I manage it right next will,
    but I will.

     
  • Fred Toussi
    Fred Toussi
    2003-03-09

    Logged In: YES
    user_id=150940

    Thanks Meikel,

    There is plenty of time. Note that the 1.7.1 version of Transfer is
    more advanced than previous versions. It can be run from the
    command line to transfer to/from a dump file, which allows a
    developer to hand-modify the dump file if necessary.

    Also the helper modules allow more options.

     
  • Meikel Bisping
    Meikel Bisping
    2003-03-18

    Logged In: YES
    user_id=599625

    Hi,

    I downloaded HSQL1_7_2_ALPHA_M and applied the patch
    to that version.

     
  • Meikel Bisping
    Meikel Bisping
    2003-03-18

    archive containing all mentioned files for version 1.7.2_ALPHA_M

     
  • Fred Toussi
    Fred Toussi
    2004-04-30

    • labels: 342511 -->
    • milestone: 110356 -->
    • assigned_to: fredt --> nobody
     
  • Fred Toussi
    Fred Toussi
    2004-04-30

    Logged In: YES
    user_id=150940

    Will check and incorporate if OK.

     
  • Meikel Bisping
    Meikel Bisping
    2004-05-03

    Logged In: YES
    user_id=599625

    transferring large tables needs a lot of memory, it would be
    good to advice users to use the java -Xmx option