|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdsu.sql.DatabaseTable
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.
Constructor Summary | |
DatabaseTable(java.sql.ResultSet dateBaseContents)
|
|
DatabaseTable(Table data)
Creates a DatabaseTable with rows equal to the table data. |
Method Summary | |
java.util.Vector |
columnAt(java.lang.String columnLabel)
Returns the column of data indicated by the columnLabel. |
int |
databaseDelete(java.lang.String dbTableName,
java.sql.Connection toDataBase)
Deletes rows of this table from a table in a database. |
int |
databaseInsert(java.lang.String dbTableName,
java.sql.Connection toDataBase)
Add rows of this table to a table in a database. |
int |
databaseInsertTest(java.lang.String dbTableName)
|
int |
databaseUpdate(java.lang.String dbTableName,
java.lang.String key,
java.sql.Connection toDataBase)
Updates rows of this table from a table in a database. |
int |
databaseUpdate(java.lang.String dbTableName,
java.util.Vector keys,
java.sql.Connection toDataBase)
Updates rows of this table from a table in a database. |
java.lang.Object |
elementAt(int row,
java.lang.String columnLabel)
Return the element in a given row and column. |
static DatabaseTable |
fromSQL(java.lang.String sqlSelect,
java.sql.Connection toDataBase)
Create a DatabaseTable object on the result of the sqlSelect query. |
java.util.Enumeration |
getColumnLabels()
Return all the column labels |
int |
getColumnType(java.lang.String columnLabel)
Set the type of the elements of a column |
static DatabaseTable |
getRow(java.lang.String tableName,
java.lang.String column,
java.lang.String columnValue,
java.sql.Connection toDataBase)
Create a DatabaseTable object containing selected rows a table from a database. |
static DatabaseTable |
getTable(java.lang.String tableName,
java.sql.Connection toDataBase)
Create a DatabaseTable object containing a table from a database. |
int |
numberOfColumns()
Returns the number of columns of data in the table. |
int |
numberOfRows()
Returns the number of rows of data in the table. |
void |
setColumnType(int type,
java.lang.String columnLabel)
Set the type of the elements of a column |
void |
setElementAt(java.lang.Object element,
int row,
java.lang.String columnLabel)
Return the element in a given row and column. |
LabeledTable |
toLabeledTable()
Convert DatabaseTable to a LabeledTable. |
java.lang.String |
toString()
|
void |
trimAll()
Remove leading and trailing spaces from all data elements |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public DatabaseTable(Table data)
public DatabaseTable(java.sql.ResultSet dateBaseContents) throws java.sql.SQLException
Method Detail |
public static DatabaseTable fromSQL(java.lang.String sqlSelect, java.sql.Connection toDataBase) throws java.sql.SQLException
sqlSelect
- sql query used to select data.toDatabase
- connection to the database that evaluates the sql query.public static DatabaseTable getTable(java.lang.String tableName, java.sql.Connection toDataBase) throws java.sql.SQLException
tableName
- the name of the table in the databasetoDatabase
- connection to the database which contains the table to be
downloaded into DatabaseTable object.public static DatabaseTable getRow(java.lang.String tableName, java.lang.String column, java.lang.String columnValue, java.sql.Connection toDataBase) throws java.sql.SQLException
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 columntoDatabase
- connection to the database which contains the table to be
downloaded into DatabaseTable object.public java.lang.String toString()
public LabeledTable toLabeledTable()
public void setColumnType(int type, java.lang.String columnLabel)
type
- the type of the elements as defined in java.sql.Types.columnLabel
- indicates the column that we are setting the typepublic int getColumnType(java.lang.String columnLabel)
public java.lang.Object elementAt(int row, java.lang.String columnLabel)
row
- index of the row of the elementcolumnLabel
- label of the column of the element. Labels are
converted to lower case to void case problems.public void setElementAt(java.lang.Object element, int row, java.lang.String columnLabel)
row
- index of the row of the elementcolumnLabel
- label of the column of the elementpublic java.util.Vector columnAt(java.lang.String columnLabel)
public int numberOfRows()
public int numberOfColumns()
public java.util.Enumeration getColumnLabels()
public void trimAll()
public int databaseInsert(java.lang.String dbTableName, java.sql.Connection toDataBase) throws java.sql.SQLException
dbTableName
- name of the table in the database which rows
will be insertedtoDataBase
- a connection to the database which contains the table
dbTableNamepublic int databaseInsertTest(java.lang.String dbTableName) throws java.sql.SQLException
public int databaseDelete(java.lang.String dbTableName, java.sql.Connection toDataBase) throws java.sql.SQLException
dbTableName
- name of the table in the database which rows
will be deletedtoDataBase
- a connection to the database which contains the table
dbTableNamepublic int databaseUpdate(java.lang.String dbTableName, java.lang.String key, java.sql.Connection toDataBase) throws java.sql.SQLException
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.public int databaseUpdate(java.lang.String dbTableName, java.util.Vector keys, java.sql.Connection toDataBase) throws java.sql.SQLException
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |