edu.mssm.crover.tables
Class AddToTable

java.lang.Object
  |
  +--edu.mssm.crover.tables.AddToTable

public class AddToTable
extends java.lang.Object

Adds to columns (and creates them if necessary) from an input file.


Field Summary
protected  java.sql.Connection conn
           
 
Constructor Summary
protected AddToTable(java.lang.String filename, java.lang.String tablename, java.lang.String[] heading, java.lang.String index)
           
 
Method Summary
 void addColumns(java.lang.String tablename, java.lang.String[] newHeadings, java.util.HashSet oldHeadings)
          Checks whether the columns to be added to already exist in the table.
 void addData(java.lang.String filename, java.lang.String tablename, java.lang.String[] newHeadings, java.lang.String index)
          Reads the input file (which should contain the same number of tab-delimited fields per line as columns you want to add to), and adds the information from each field in each line to the corresponding column.
 void begin()
          Notifies this class that a batch of interaction now begin.
 java.util.HashSet describeTable(java.lang.String tablename)
          Uses SQL to describe the table, and puts the column headings into a HashSet.
 void end()
          Notifies this class that a batch of interaction now ends.
static java.lang.String[] getHeading(java.lang.String[] args)
          Returns the name of the table to which the data is to be added.
static java.lang.String getIndexColumn(java.lang.String[] args)
          Returns the name of the column to be used as an identifier.
static java.lang.String getInputFile(java.lang.String[] args)
          Returns the name of the input file.
static AddToTable getInstance(java.lang.String filename, java.lang.String tablename, java.lang.String[] heading, java.lang.String index)
           
static java.lang.String getTableName(java.lang.String[] args)
          Returns the name of the table to which the data is to be added.
protected  void initConnection()
          Makes sure a connection is available.
static void main(java.lang.String[] args)
           
static void printHelp()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected java.sql.Connection conn
Constructor Detail

AddToTable

protected AddToTable(java.lang.String filename,
                     java.lang.String tablename,
                     java.lang.String[] heading,
                     java.lang.String index)
              throws DatabaseErrorException
Method Detail

getInputFile

public static java.lang.String getInputFile(java.lang.String[] args)
Returns the name of the input file. Read from the command line, after "-i" flag. Each line contains tab-delimited data to be entered into different columns. This is a necessary parameter.


getTableName

public static java.lang.String getTableName(java.lang.String[] args)
Returns the name of the table to which the data is to be added. Read from the command line, after "-t" flag. This is a necessary parameter.


getHeading

public static java.lang.String[] getHeading(java.lang.String[] args)
Returns the name of the table to which the data is to be added. Read from the command line, after "-t" flag. This is a necessary parameter.


getIndexColumn

public static java.lang.String getIndexColumn(java.lang.String[] args)
Returns the name of the column to be used as an identifier. Read from the command line, after the "-index" flag. This is a necessary parameter.


printHelp

public static void printHelp()

describeTable

public java.util.HashSet describeTable(java.lang.String tablename)
                                throws java.sql.SQLException
Uses SQL to describe the table, and puts the column headings into a HashSet.

java.sql.SQLException

addColumns

public void addColumns(java.lang.String tablename,
                       java.lang.String[] newHeadings,
                       java.util.HashSet oldHeadings)
                throws java.sql.SQLException
Checks whether the columns to be added to already exist in the table. If not, they are added. A default type of varchar2(80) is assigned to them.

java.sql.SQLException

addData

public void addData(java.lang.String filename,
                    java.lang.String tablename,
                    java.lang.String[] newHeadings,
                    java.lang.String index)
             throws java.sql.SQLException,
                    java.io.FileNotFoundException,
                    java.io.IOException,
                    DatabaseErrorException
Reads the input file (which should contain the same number of tab-delimited fields per line as columns you want to add to), and adds the information from each field in each line to the corresponding column. The input file should contain as a first field the values of the index column.

java.sql.SQLException
java.io.FileNotFoundException
java.io.IOException
DatabaseErrorException

begin

public void begin()
           throws DatabaseErrorException
Notifies this class that a batch of interaction now begin. Allows specific optimization to be performed.

DatabaseErrorException

end

public void end()
         throws DatabaseErrorException
Notifies this class that a batch of interaction now ends. Allows specific optimization to be performed.

DatabaseErrorException

initConnection

protected void initConnection()
                       throws DatabaseErrorException
Makes sure a connection is available.

DatabaseErrorException

getInstance

public static AddToTable getInstance(java.lang.String filename,
                                     java.lang.String tablename,
                                     java.lang.String[] heading,
                                     java.lang.String index)
                              throws DatabaseErrorException
DatabaseErrorException

main

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


Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.