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: 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.

Variable Index

 o DEFAULT_DRIVER
Default database driver ("sun.jdbc.odbc.JdbcOdbcDriver").
 o DEFAULT_QUERY
Default query ("SELECT * FROM {0}", {0} == table name).
 o DEFAULT_URL
Default database URL ("jdbc:odbc:{0}", {0} == database name).
 o DEFAULT_USER_NAME
Default user name ("").
 o DEFAULT_USER_PASSWORD
Default password ("").

Constructor Index

 o DatabaseTable()
Constructs an empty table.
 o DatabaseTable(String, String, String, String)
Constructs a database table from the specified database URL, user name, user password, and query string.
 o DatabaseTable(String, String, String, String, String)
Constructs a database table from the specified driver, database URL, user name, user password, and query string.

Method Index

 o addColumn(Object[], Object)
Not allowed to add a column.
 o addRow(Object[], Object)
Adds a row.
 o addTableListener(TableListener)
Adds a table listener.
 o getColumnCount()
Returns the number of columns in the table.
 o getColumnIndex(Object)
Returns the index of the first column information that equals the specified information or -1 if no column information matches.
 o getColumnInfo(int)
Returns the specified column's information.
 o getDriver()
Returns the current database driver.
 o getElement(int, int)
Returns the element at the specified <row, col>.
 o getQuery()
Returns the current query string.
 o getRowCount()
Returns the number of rows in the table.
 o getRowIndex(Object)
Returns the index of the first row information that equals the specified information or -1 if no column information matches.
 o getRowInfo(int)
Returns the specified row's information.
 o getUrl()
Returns the URL of the database.
 o getUserName()
Returns the user name of the database.
 o getUserPassword()
Returns the user password of the database.
 o insertColumn(Object[], Object, int)
Not allowed to insert a column.
 o insertRow(Object[], Object, int)
Insert a row at the specified index.
 o isConnected()
Returns true if the database connection has been made.
 o removeAllColumns()
Not allowed to remove all of the columns in the table.
 o removeAllRows()
Removes all of the rows in the table.
 o removeColumn(int)
Not allowed to remove a column.
 o removeRow(int)
Removes specified row.
 o removeTableListener(TableListener)
Removes the specified table listener.
 o replaceColumn(Object[], Object, int)
Not allowed to replace a column.
 o replaceRow(Object[], Object, int)
Replaces the row at the specified index.
 o setColumnInfo(Object, int)
Sets the specified column's information.
 o setConnected(boolean)
Sets whether the database is connected or not.
 o setDriver(String)
Sets the database driver used to establish the connection.
 o setElement(Object, int, int)
Sets the element at the specified <row, col>.
 o setQuery(String)
Sets the query string.
 o setRowInfo(Object, int)
Sets the specified row's information.
 o setUrl(String)
Sets the URL of the database.
 o setUserName(String)
Sets the user name of the database.
 o setUserPassword(String)
Sets the user password of the database.

Variables

 o DEFAULT_DRIVER
 public static final String DEFAULT_DRIVER
Default database driver ("sun.jdbc.odbc.JdbcOdbcDriver").

 o 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().

 o DEFAULT_USER_NAME
 public static final String DEFAULT_USER_NAME
Default user name ("").

 o DEFAULT_USER_PASSWORD
 public static final String DEFAULT_USER_PASSWORD
Default password ("").

 o 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().

Constructors

 o DatabaseTable
 public DatabaseTable()
Constructs an empty table.

 o 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
 o 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

Methods

 o 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
 o getDriver
 public String getDriver()
Returns the current database driver.

See Also:
setDriver
 o setUrl
 public void setUrl(String url)
Sets the URL of the database.

Parameters:
url - The new URL.
See Also:
getUrl, DEFAULT_URL
 o getUrl
 public String getUrl()
Returns the URL of the database.

See Also:
setUrl
 o setUserName
 public void setUserName(String name)
Sets the user name of the database.

Parameters:
name - The user name.
See Also:
getUserName, DEFAULT_USER_NAME
 o getUserName
 public String getUserName()
Returns the user name of the database.

See Also:
setUserName
 o setUserPassword
 public void setUserPassword(String pwd)
Sets the user password of the database.

Parameters:
pwd - The user password.
See Also:
getUserPassword, DEFAULT_USER_PASSWORD
 o getUserPassword
 public String getUserPassword()
Returns the user password of the database.

See Also:
setUserPassword
 o setQuery
 public void setQuery(String query)
Sets the query string.

Parameters:
query - The new query string.
See Also:
getQuery, DEFAULT_QUERY
 o getQuery
 public String getQuery()
Returns the current query string.

See Also:
setQuery
 o 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
 o isConnected
 public boolean isConnected()
Returns true if the database connection has been made.

See Also:
setConnected
 o addTableListener
 public void addTableListener(TableListener listener)
Adds a table listener.

Overrides:
addTableListener in class TableModel
 o removeTableListener
 public void removeTableListener(TableListener listener)
Removes the specified table listener.

Overrides:
removeTableListener in class TableModel
 o 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
 o 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
 o getColumnCount
 public int getColumnCount()
Returns the number of columns in the table.

Overrides:
getColumnCount in class TableModel
 o 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
 o getColumnInfo
 public synchronized Object getColumnInfo(int col)
Returns the specified column's information.

Parameters:
col - The column index.
Overrides:
getColumnInfo in class TableModel
 o 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
 o addColumn
 public void addColumn(Object data[],
                       Object info)
Not allowed to add a column.

Overrides:
addColumn in class TableModel
 o removeColumn
 public void removeColumn(int col)
Not allowed to remove a column.

Overrides:
removeColumn in class TableModel
 o removeAllColumns
 public void removeAllColumns()
Not allowed to remove all of the columns in the table.

Overrides:
removeAllColumns in class TableModel
 o insertColumn
 public void insertColumn(Object data[],
                          Object info,
                          int col)
Not allowed to insert a column.

Overrides:
insertColumn in class TableModel
 o replaceColumn
 public void replaceColumn(Object data[],
                           Object info,
                           int col)
Not allowed to replace a column.

Overrides:
replaceColumn in class TableModel
 o getRowCount
 public synchronized int getRowCount()
Returns the number of rows in the table.

Overrides:
getRowCount in class TableModel
 o 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
 o getRowInfo
 public Object getRowInfo(int row)
Returns the specified row's information.

Parameters:
row - The row index.
Overrides:
getRowInfo in class TableModel
 o 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
 o 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
 o removeRow
 public void removeRow(int row)
Removes specified row.

Parameters:
row - The row index.
Overrides:
removeRow in class TableModel
 o removeAllRows
 public void removeAllRows()
Removes all of the rows in the table.

Overrides:
removeAllRows in class TableModel
 o 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
 o 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