All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.sql.DatabaseTable
java.lang.Object
|
+----sdsu.sql.DatabaseTable
- public class DatabaseTable
- extends Object
A class defines an interface for transfering tables between Java and
a database. This class is easy to misuse. You still should use SQL to
have the database perform the query, don't just download all the
tables and then perform queries.
- Version:
- 0.5 12 July 1997
- Author:
- Roger Whitney
(whitney@cs.sdsu.edu)
-
DatabaseTable(ResultSet)
-
-
DatabaseTable(Table)
- Creates a DatabaseTable with rows equal to the table data.
-
columnAt(String)
- Returns the column of data indicated by the columnLabel.
-
databaseDelete(String, Connection)
- Deletes rows of this table from a table in a database.
-
databaseInsert(String, Connection)
- Add rows of this table to a table in a database.
-
databaseInsertTest(String)
-
-
databaseUpdate(String, String, Connection)
- Updates rows of this table from a table in a database.
-
databaseUpdate(String, Vector, Connection)
- Updates rows of this table from a table in a database.
-
elementAt(int, String)
- Return the element in a given row and column.
-
fromSQL(String, Connection)
- Create a DatabaseTable object on the result of the sqlSelect query.
-
getColumnLabels()
- Return all the column labels
-
getColumnType(String)
- Set the type of the elements of a column
-
getRow(String, String, String, Connection)
- Create a DatabaseTable object containing selected rows a table from a database.
-
getTable(String, Connection)
- Create a DatabaseTable object containing a table from a database.
-
numberOfColumns()
- Returns the number of columns of data in the table.
-
numberOfRows()
- Returns the number of rows of data in the table.
-
setColumnType(int, String)
- Set the type of the elements of a column
-
setElementAt(Object, int, String)
- Return the element in a given row and column.
-
toLabeledTable()
- Convert DatabaseTable to a LabeledTable.
-
toString()
-
-
trimAll()
-
Remove leading and trailing spaces from all data elements
DatabaseTable
public DatabaseTable(Table data)
- Creates a DatabaseTable with rows equal to the table data.
DatabaseTable
public DatabaseTable(ResultSet dateBaseContents) throws SQLException
fromSQL
public static DatabaseTable fromSQL(String sqlSelect,
Connection toDataBase) throws SQLException
- Create a DatabaseTable object on the result of the sqlSelect query.
- Parameters:
- sqlSelect - sql query used to select data.
- toDatabase - connection to the database that evaluates the sql query.
- Throws: SQLException
- thrown on any error connecting to database or
satisfying the query
getTable
public static DatabaseTable getTable(String tableName,
Connection toDataBase) throws SQLException
- Create a DatabaseTable object containing a table from a database.
- Parameters:
- tableName - the name of the table in the database
- toDatabase - connection to the database which contains the table to be
downloaded into DatabaseTable object.
- Throws: SQLException
- thrown on any error connecting to database or obtaining
the table.
getRow
public static DatabaseTable getRow(String tableName,
String column,
String columnValue,
Connection toDataBase) throws SQLException
- Create a DatabaseTable object containing selected rows a table from a database.
- Parameters:
- tableName - the name of the table in the database.
- column - a column label in the table.
- columnValue - select all rows that have this value in the given column
- toDatabase - connection to the database which contains the table to be
downloaded into DatabaseTable object.
- Throws: SQLException
- thrown on any error connecting to database or obtaining
the table.
toString
public String toString()
- Overrides:
- toString in class Object
toLabeledTable
public LabeledTable toLabeledTable()
- Convert DatabaseTable to a LabeledTable. Row zero contains the
column vectors.
setColumnType
public void setColumnType(int type,
String columnLabel)
- Set the type of the elements of a column
- Parameters:
- type - the type of the elements as defined in java.sql.Types.
- columnLabel - indicates the column that we are setting the type
getColumnType
public int getColumnType(String columnLabel)
- Set the type of the elements of a column
elementAt
public Object elementAt(int row,
String columnLabel)
- Return the element in a given row and column. Rows start at
one.
- Parameters:
- row - index of the row of the element
- columnLabel - label of the column of the element. Labels are
converted to lower case to void case problems.
setElementAt
public void setElementAt(Object element,
int row,
String columnLabel)
- Return the element in a given row and column. Rows start at
one.
- Parameters:
- row - index of the row of the element
- columnLabel - label of the column of the element
columnAt
public Vector columnAt(String columnLabel)
- Returns the column of data indicated by the columnLabel.
Column label is not in the returned vector.
numberOfRows
public int numberOfRows()
- Returns the number of rows of data in the table.
numberOfColumns
public int numberOfColumns()
- Returns the number of columns of data in the table.
getColumnLabels
public Enumeration getColumnLabels()
- Return all the column labels
trimAll
public void trimAll()
- Remove leading and trailing spaces from all data elements
databaseInsert
public int databaseInsert(String dbTableName,
Connection toDataBase) throws SQLException
- Add rows of this table to a table in a database.
- Parameters:
- dbTableName - name of the table in the database which rows
will be inserted
- toDataBase - a connection to the database which contains the table
dbTableName
- Returns:
- total number of rows that were added to database table
databaseInsertTest
public int databaseInsertTest(String dbTableName) throws SQLException
databaseDelete
public int databaseDelete(String dbTableName,
Connection toDataBase) throws SQLException
- Deletes rows of this table from a table in a database. Rows in
the database table with are identical to the rows in this table
will be deleted.
- Parameters:
- dbTableName - name of the table in the database which rows
will be deleted
- toDataBase - a connection to the database which contains the table
dbTableName
databaseUpdate
public int databaseUpdate(String dbTableName,
String key,
Connection toDataBase) throws SQLException
- Updates rows of this table from a table in a database. Rows in
the database table with are identical to the rows in this table
will be deleted.
- Parameters:
- dbTableName - name of the table in the database which
will be updated.
- key - column label used to select which rows in the database
table to update. Any row in the database table that has the same value
in the column indicated by key as a row in this table will be updated.
- toDataBase - a connection to the database which contains the table
dbTableName.
databaseUpdate
public int databaseUpdate(String dbTableName,
Vector keys,
Connection toDataBase) throws SQLException
- Updates rows of this table from a table in a database. Rows in
the database table with are identical to the rows in this table
will be deleted.
- Parameters:
- dbTableName - name of the table in the database which
will be updated.
- keys - Vector of column labela used to select which rows in the database
table to update. Any row in the database table that has the same value
in the columns indicated by keys as a row in this table will be updated.
- toDataBase - a connection to the database which contains the table
dbTableName.
All Packages Class Hierarchy This Package Previous Next Index