org.formaria.util
Class DatabaseTransferManager

java.lang.Object
  extended by org.formaria.util.DatabaseTransferManager

public class DatabaseTransferManager
extends java.lang.Object

Transfer data between two JDBC databases

Copyright (c) Formaria Ltd., 2008, This software is licensed under the GNU Public License (GPL), please see license.txt for more details. If you make commercial use of this software you must purchase a commercial license from formaria.

$Revision: 1.6 $


Field Summary
protected  boolean dropTables
           
protected  java.util.prefs.Preferences prefs
           
protected  java.sql.Connection sourceConn
           
protected  java.lang.String sourceConnectionString
           
protected  java.lang.String sourceDriverName
           
protected  java.lang.String sourcePassword
           
protected  java.lang.String sourceUserName
           
protected  java.sql.Connection targetConn
           
protected  java.lang.String targetConnectionString
           
protected  java.lang.String targetDriverName
           
protected  java.lang.String targetPassword
           
protected  java.lang.String targetUserName
           
 
Constructor Summary
DatabaseTransferManager()
          Creates a new instance of TransferManager
 
Method Summary
 void clearTable(java.lang.String tableName)
          Empty the table of existing data
 void closeConnections()
          Setup a connection to the target or sink database
 void copyTableData(java.lang.String tableName)
          Copy the table's data
 void copyTables()
          Copy tables between the source and sink
 void createTable(java.lang.String tableName)
          Create a table in the target database
 void doTransfer()
           
 void dropTable(java.lang.String tableName)
          Drop the target table if it exists
 java.sql.Connection getConnection(java.lang.String driver, java.lang.String urlStr, java.lang.String userName, java.lang.String password)
          Gets a database connection
 boolean getConnectionParameters(boolean isSource)
          Ask the user for the connection parameters
static void main(java.lang.String[] args)
           
 void setupDataSource()
          Setup a connection to the source database
 void setupDataTarget()
          Setup a connection to the target or sink database
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceDriverName

protected java.lang.String sourceDriverName

sourceConnectionString

protected java.lang.String sourceConnectionString

sourceUserName

protected java.lang.String sourceUserName

sourcePassword

protected java.lang.String sourcePassword

targetDriverName

protected java.lang.String targetDriverName

targetConnectionString

protected java.lang.String targetConnectionString

targetUserName

protected java.lang.String targetUserName

targetPassword

protected java.lang.String targetPassword

sourceConn

protected java.sql.Connection sourceConn

targetConn

protected java.sql.Connection targetConn

dropTables

protected boolean dropTables

prefs

protected java.util.prefs.Preferences prefs
Constructor Detail

DatabaseTransferManager

public DatabaseTransferManager()
Creates a new instance of TransferManager

Method Detail

main

public static void main(java.lang.String[] args)

doTransfer

public void doTransfer()

setupDataSource

public void setupDataSource()
Setup a connection to the source database


setupDataTarget

public void setupDataTarget()
Setup a connection to the target or sink database


closeConnections

public void closeConnections()
Setup a connection to the target or sink database


copyTables

public void copyTables()
Copy tables between the source and sink


dropTable

public void dropTable(java.lang.String tableName)
Drop the target table if it exists

Parameters:
tableName - the name of the table to delete/drop

clearTable

public void clearTable(java.lang.String tableName)
Empty the table of existing data

Parameters:
tableName - the name of the table to delete/drop

createTable

public void createTable(java.lang.String tableName)
Create a table in the target database

Parameters:
tableName - the name of the table to delete/drop

copyTableData

public void copyTableData(java.lang.String tableName)
Copy the table's data

Parameters:
tableName - the name of the table

getConnectionParameters

public boolean getConnectionParameters(boolean isSource)
Ask the user for the connection parameters

Parameters:
isSource - true if the source parameters are being queried
Returns:
true if the input is ok

getConnection

public java.sql.Connection getConnection(java.lang.String driver,
                                         java.lang.String urlStr,
                                         java.lang.String userName,
                                         java.lang.String password)
Gets a database connection

Parameters:
driver - the jdbc driver class name
urlStr - the url of the database
userName - the user name to use in making the connections
password - the connection password