All Packages Class Hierarchy This Package Previous Next Index
Class COM.taligent.util.DatabaseTable
java.lang.Object
|
+----COM.taligent.util.TableModel
|
+----COM.taligent.util.DatabaseTable
- public class DatabaseTable
- extends TableModel
A database table object. To connect to a database you need to
set the following properties:
- driver (can leave as default if using JDBC-ODBC bridge)
- url
- query
and finally set the connected property to true.
The connected property is what connects to the database. The
model will not pull data from the database until it is
connected.
This class doesn't modify the database. Consider the current
DatabaseTable implementation as read only.
- Version:
- 1.0
- Author:
- Andy Clark, Taligent Inc.
-
DEFAULT_DRIVER
- Default database driver ("sun.jdbc.odbc.JdbcOdbcDriver").
-
DEFAULT_QUERY
- Default query ("SELECT * FROM {0}", {0} == table name).
-
DEFAULT_URL
- Default database URL ("jdbc:odbc:{0}", {0} == database name).
-
DEFAULT_USER_NAME
- Default user name ("").
-
DEFAULT_USER_PASSWORD
- Default password ("").
-
DatabaseTable()
- Constructs an empty table.
-
DatabaseTable(String, String, String, String)
- Constructs a database table from the specified database URL,
user name, user password, and query string.
-
DatabaseTable(String, String, String, String, String)
- Constructs a database table from the specified driver, database
URL, user name, user password, and query string.
-
addColumn(Object[], Object)
- Not allowed to add a column.
-
addRow(Object[], Object)
- Adds a row.
-
addTableListener(TableListener)
- Adds a table listener.
-
getColumnCount()
- Returns the number of columns in the table.
-
getColumnIndex(Object)
- Returns the index of the first column information that equals
the specified information or -1 if no column information matches.
-
getColumnInfo(int)
- Returns the specified column's information.
-
getDriver()
- Returns the current database driver.
-
getElement(int, int)
- Returns the element at the specified <row, col>.
-
getQuery()
- Returns the current query string.
-
getRowCount()
- Returns the number of rows in the table.
-
getRowIndex(Object)
- Returns the index of the first row information that equals
the specified information or -1 if no column information matches.
-
getRowInfo(int)
- Returns the specified row's information.
-
getUrl()
- Returns the URL of the database.
-
getUserName()
- Returns the user name of the database.
-
getUserPassword()
- Returns the user password of the database.
-
insertColumn(Object[], Object, int)
- Not allowed to insert a column.
-
insertRow(Object[], Object, int)
- Insert a row at the specified index.
-
isConnected()
- Returns true if the database connection has been made.
-
removeAllColumns()
- Not allowed to remove all of the columns in the table.
-
removeAllRows()
- Removes all of the rows in the table.
-
removeColumn(int)
- Not allowed to remove a column.
-
removeRow(int)
- Removes specified row.
-
removeTableListener(TableListener)
- Removes the specified table listener.
-
replaceColumn(Object[], Object, int)
- Not allowed to replace a column.
-
replaceRow(Object[], Object, int)
- Replaces the row at the specified index.
-
setColumnInfo(Object, int)
- Sets the specified column's information.
-
setConnected(boolean)
- Sets whether the database is connected or not.
-
setDriver(String)
- Sets the database driver used to establish the connection.
-
setElement(Object, int, int)
- Sets the element at the specified <row, col>.
-
setQuery(String)
- Sets the query string.
-
setRowInfo(Object, int)
- Sets the specified row's information.
-
setUrl(String)
- Sets the URL of the database.
-
setUserName(String)
- Sets the user name of the database.
-
setUserPassword(String)
- Sets the user password of the database.
DEFAULT_DRIVER
public static final String DEFAULT_DRIVER
- Default database driver ("sun.jdbc.odbc.JdbcOdbcDriver").
DEFAULT_URL
public static final String DEFAULT_URL
- Default database URL ("jdbc:odbc:{0}", {0} == database name).
The user of the DatabaseTable can use the MessageFormat.format()
method with the default URL string to insert the necessary
database name when calling setUrl().
DEFAULT_USER_NAME
public static final String DEFAULT_USER_NAME
- Default user name ("").
DEFAULT_USER_PASSWORD
public static final String DEFAULT_USER_PASSWORD
- Default password ("").
DEFAULT_QUERY
public static final String DEFAULT_QUERY
- Default query ("SELECT * FROM {0}", {0} == table name). The
user of the DatabaseTable can use the MessageFormat.format()
method with the default query string to insert the necessary
table name when calling setQuery().
DatabaseTable
public DatabaseTable()
- Constructs an empty table.
DatabaseTable
public DatabaseTable(String url,
String name,
String pwd,
String query)
- Constructs a database table from the specified database URL,
user name, user password, and query string.
- Parameters:
- url - The database URL.
- name - The user name.
- pwd - The user password.
- query - The query string.
- See Also:
- DEFAULT_URL, DEFAULT_USER_NAME, DEFAULT_USER_PASSWORD, DEFAULT_QUERY
DatabaseTable
public DatabaseTable(String driver,
String url,
String name,
String pwd,
String query)
- Constructs a database table from the specified driver, database
URL, user name, user password, and query string.
- Parameters:
- driver - The fully qualified class name of the driver.
- url - The database URL.
- name - The user name.
- pwd - The user password.
- query - The query string.
- See Also:
- DEFAULT_DRIVER, DEFAULT_URL, DEFAULT_USER_NAME, DEFAULT_USER_PASSWORD, DEFAULT_QUERY
setDriver
public void setDriver(String driver)
- Sets the database driver used to establish the connection.
- Parameters:
- driver - The fully qualified class name of the
database driver.
- See Also:
- getDriver, DEFAULT_DRIVER
getDriver
public String getDriver()
- Returns the current database driver.
- See Also:
- setDriver
setUrl
public void setUrl(String url)
- Sets the URL of the database.
- Parameters:
- url - The new URL.
- See Also:
- getUrl, DEFAULT_URL
getUrl
public String getUrl()
- Returns the URL of the database.
- See Also:
- setUrl
setUserName
public void setUserName(String name)
- Sets the user name of the database.
- Parameters:
- name - The user name.
- See Also:
- getUserName, DEFAULT_USER_NAME
getUserName
public String getUserName()
- Returns the user name of the database.
- See Also:
- setUserName
setUserPassword
public void setUserPassword(String pwd)
- Sets the user password of the database.
- Parameters:
- pwd - The user password.
- See Also:
- getUserPassword, DEFAULT_USER_PASSWORD
getUserPassword
public String getUserPassword()
- Returns the user password of the database.
- See Also:
- setUserPassword
setQuery
public void setQuery(String query)
- Sets the query string.
- Parameters:
- query - The new query string.
- See Also:
- getQuery, DEFAULT_QUERY
getQuery
public String getQuery()
- Returns the current query string.
- See Also:
- setQuery
setConnected
public void setConnected(boolean connected)
- Sets whether the database is connected or not.
- Parameters:
- connected - True to connect to database, false to remain
unconnected.
- See Also:
- isConnected
isConnected
public boolean isConnected()
- Returns true if the database connection has been made.
- See Also:
- setConnected
addTableListener
public void addTableListener(TableListener listener)
- Adds a table listener.
- Overrides:
- addTableListener in class TableModel
removeTableListener
public void removeTableListener(TableListener listener)
- Removes the specified table listener.
- Overrides:
- removeTableListener in class TableModel
setElement
public void setElement(Object element,
int row,
int col)
- Sets the element at the specified <row, col>.
- Parameters:
- element - The new element.
- row - The row index.
- col - The column index.
- Overrides:
- setElement in class TableModel
getElement
public synchronized Object getElement(int row,
int col)
- Returns the element at the specified <row, col>.
- Parameters:
- row - The row index.
- col - The column index.
- Overrides:
- getElement in class TableModel
getColumnCount
public int getColumnCount()
- Returns the number of columns in the table.
- Overrides:
- getColumnCount in class TableModel
setColumnInfo
public void setColumnInfo(Object info,
int col)
- Sets the specified column's information.
- Parameters:
- info - The column information.
- col - The column index.
- Overrides:
- setColumnInfo in class TableModel
getColumnInfo
public synchronized Object getColumnInfo(int col)
- Returns the specified column's information.
- Parameters:
- col - The column index.
- Overrides:
- getColumnInfo in class TableModel
getColumnIndex
public synchronized int getColumnIndex(Object info)
- Returns the index of the first column information that equals
the specified information or -1 if no column information matches.
- Parameters:
- info - The column information.
- Overrides:
- getColumnIndex in class TableModel
addColumn
public void addColumn(Object data[],
Object info)
- Not allowed to add a column.
- Overrides:
- addColumn in class TableModel
removeColumn
public void removeColumn(int col)
- Not allowed to remove a column.
- Overrides:
- removeColumn in class TableModel
removeAllColumns
public void removeAllColumns()
- Not allowed to remove all of the columns in the table.
- Overrides:
- removeAllColumns in class TableModel
insertColumn
public void insertColumn(Object data[],
Object info,
int col)
- Not allowed to insert a column.
- Overrides:
- insertColumn in class TableModel
replaceColumn
public void replaceColumn(Object data[],
Object info,
int col)
- Not allowed to replace a column.
- Overrides:
- replaceColumn in class TableModel
getRowCount
public synchronized int getRowCount()
- Returns the number of rows in the table.
- Overrides:
- getRowCount in class TableModel
setRowInfo
public void setRowInfo(Object info,
int row)
- Sets the specified row's information.
- Parameters:
- info - The row information.
- row - The row index.
- Overrides:
- setRowInfo in class TableModel
getRowInfo
public Object getRowInfo(int row)
- Returns the specified row's information.
- Parameters:
- row - The row index.
- Overrides:
- getRowInfo in class TableModel
getRowIndex
public synchronized int getRowIndex(Object info)
- Returns the index of the first row information that equals
the specified information or -1 if no column information matches.
- Parameters:
- info - The row information.
- Overrides:
- getRowIndex in class TableModel
addRow
public void addRow(Object data[],
Object info)
- Adds a row.
- Parameters:
- data - The new row's data. Can be null. If the data
array length is shorter than the number of
columns, then null values will be added; and if
the length is greater than the number of columns,
the extraneous values are ignored.
- info - The new row's information. Can be null.
- Overrides:
- addRow in class TableModel
removeRow
public void removeRow(int row)
- Removes specified row.
- Parameters:
- row - The row index.
- Overrides:
- removeRow in class TableModel
removeAllRows
public void removeAllRows()
- Removes all of the rows in the table.
- Overrides:
- removeAllRows in class TableModel
insertRow
public void insertRow(Object data[],
Object info,
int row)
- Insert a row at the specified index.
- Parameters:
- data - The new row's data. Can be null. If the data
array length is shorter than the number of
columns, then null values will be added; and if
the length is greater than the number of columns,
the extraneous values are ignored.
- info - The new row's information.
- row - The row index.
- Overrides:
- insertRow in class TableModel
replaceRow
public void replaceRow(Object data[],
Object info,
int row)
- Replaces the row at the specified index. The implementer of
this method should send TableEvent.ROW_CHANGED events to the
registered table listeners.
- Parameters:
- data - The row's new data. Can be null. If the data
array length is shorter than the number of
columns, then null values will be added; and if
the length is greater than the number of columns,
the extraneous values are ignored.
- info - The row's new information. Can be null.
- row - The row index.
- Overrides:
- replaceRow in class TableModel
All Packages Class Hierarchy This Package Previous Next Index