|
TissueInfo API 20091124110011 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.mssm.crover.tables.AddToTable
public class AddToTable
Adds to columns (and creates them if necessary) from an input file.
| Field Summary | |
|---|---|
protected Connection |
conn
The connection to the database used by this instance. |
| Constructor Summary | |
|---|---|
protected |
AddToTable(String filename,
String tablename,
String[] heading,
String index)
Adds the data to the specified table. |
| Method Summary | |
|---|---|
void |
addColumns(String tablename,
String[] newHeadings,
HashSet oldHeadings)
Checks whether the columns to be added to already exist in the table. |
void |
addData(String filename,
String tablename,
String[] newHeadings,
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. |
HashSet |
describeTable(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 String[] |
getHeading(String[] args)
Returns the name of the headings in the table to which the data are to be added. |
static String |
getIndexColumn(String[] args)
Returns the name of the column to be used as an identifier. |
static String |
getInputFile(String[] args)
Returns the name of the input file. |
static AddToTable |
getInstance(String filename,
String tablename,
String[] heading,
String index)
Gets an instance of this class. |
static String |
getTableName(String[] args)
Returns the name of the table to which the data are to be added. |
protected void |
initConnection()
Makes sure a connection is available. |
static void |
main(String[] args)
Main method. |
static void |
printHelp()
Prints the help menu. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Connection conn
| Constructor Detail |
|---|
protected AddToTable(String filename,
String tablename,
String[] heading,
String index)
throws DatabaseErrorException
filename - The name of the input file containing the data.tablename - The name of the table to be modified.heading - The headings of the columns to which the data will be
added.index - The name of the identifier column.
DatabaseErrorException - if there is a problem connecting to the
database.| Method Detail |
|---|
public static String getInputFile(String[] args)
args - Thcommand line arguments.
public static String getTableName(String[] args)
args - The command line arguments.
public static String[] getHeading(String[] args)
args - The command line arguments.
public static String getIndexColumn(String[] args)
args - The command line arguments.
public static void printHelp()
public final HashSet describeTable(String tablename)
throws SQLException
tablename - The name of the table to be described.
SQLException - if there is a problem querying the database.
public final void addColumns(String tablename,
String[] newHeadings,
HashSet oldHeadings)
throws SQLException
tablename - The name of the table to be modified.newHeadings - The headings of the columns to be added to the
specified table.oldHeadings - The headings of the columns already present in the
specified table.
SQLException - if there is a problem querying the database.
public final void addData(String filename,
String tablename,
String[] newHeadings,
String index)
throws SQLException,
IOException,
DatabaseErrorException
filename - The name of the input file containing the data.tablename - The name of the table to be modified.newHeadings - The headings of the columns to be added to the
specified table (if they do not already exist).index - The heading of the identifier column.
SQLException - if there is a problem querying the database.
IOException - if there is a problem reading the input file.
DatabaseErrorException - if there is a problem connecting to the
database.
public final void begin()
throws DatabaseErrorException
DatabaseErrorException - if there is a problem connecting to the
database.public final void end()
protected final void initConnection()
throws DatabaseErrorException
DatabaseErrorException - if there is a problem connecting to the
database.
public static AddToTable getInstance(String filename,
String tablename,
String[] heading,
String index)
throws DatabaseErrorException
filename - The name of the input file containing the data.tablename - The name of the table to be modified.heading - The headings of the columns to be added to the specified
table (if they do not already exist).index - The heading of the identifier column.
DatabaseErrorException - if there is a problem connecting to the
database.public static void main(String[] args)
args - The command line arguments.
|
TissueInfo API 20091124110011 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||