|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.table.AbstractTableModel ca.idms.jcf.JdbcTable
public class JdbcTable
Converts the JDBC interface to the TableModel interface. This class can be used to implement a simple SQL utility that will execute update and query statements. The JTable data itself is not directly updatable. This class should work with any JDBC driver that does not requite catalog qualifiers in tables names for the DatabaseMetaData queries.
Note: This source code and the classes compiled from it are provided only for demonstration purposes, and are not a supported part of the CA IDMS Server product.
This class was converted to use generic types for CA IDMS Server r17 and requires Java 1.5 or later.
Field Summary | |
---|---|
protected java.sql.Connection |
conn
|
protected java.sql.SQLException |
ex
|
protected java.sql.ResultSetMetaData |
md
|
protected java.sql.DatabaseMetaData |
meta
|
protected java.lang.String[] |
names
Column names. |
protected java.util.Vector<java.util.Vector<java.lang.Object>> |
rows
Column values. |
protected java.sql.Statement |
stmt
|
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
JdbcTable(java.lang.String driver)
Constructs an object to execute SQL statements. |
Method Summary | |
---|---|
void |
close()
Closes the SQL statement and connection. |
void |
connect(java.lang.String url,
java.lang.String uid,
java.lang.String pwd)
Connects to the database. |
protected void |
error(java.lang.Exception e)
Returns a message in the JTable. |
protected void |
error(java.sql.SQLException e)
Returns SQL error messages in the JTable. |
void |
execute(java.lang.String sql)
Excecutes an SQL statement. |
protected void |
finalize()
|
void |
getBestRowIdentifier(java.lang.String sp,
java.lang.String tab,
boolean nullable)
Issues a JDBC getBestRowIdentifier() request. |
java.lang.Class<?> |
getColumnClass(int col)
|
int |
getColumnCount()
|
java.lang.String |
getColumnName(int col)
|
void |
getColumns(java.lang.String sp,
java.lang.String tp,
java.lang.String cp)
Issues a JDBC getColumns() request. |
int |
getColumnWidth(int col)
Gets preferred column width. |
void |
getCrossReference(java.lang.String pk_sp,
java.lang.String pk_tab,
java.lang.String fk_sp,
java.lang.String fk_tab)
Issues a JDBC getCrossReference() request. |
void |
getExportedKeys(java.lang.String sp,
java.lang.String tab)
Issues a JDBC getExportedKeys() request. |
void |
getImportedKeys(java.lang.String sp,
java.lang.String tab)
Issues a JDBC getImportedKeys() request. |
void |
getIndexInfo(java.lang.String sp,
java.lang.String tab,
boolean unique)
Issues a JDBC getIndexInfo() request. |
void |
getPrimaryKeys(java.lang.String sp,
java.lang.String tab)
Issues a JDBC getPrimaryKeys() request. |
void |
getProcedureColumns(java.lang.String sp,
java.lang.String tp,
java.lang.String cp)
Issues a JDBC getProcedureColumns() request. |
void |
getProcedures(java.lang.String sp,
java.lang.String tp)
Issues a JDBC getProcedures() request. |
int |
getRowCount()
|
void |
getSchemas()
Issues a JDBC getSchemas() request. |
void |
getTables(java.lang.String sp,
java.lang.String tp)
Issues a JDBC getTables() request. |
java.lang.Object |
getValueAt(int r,
int c)
|
protected void |
reset()
Resets references. |
protected void |
result(java.sql.ResultSet rs)
Return the result set for an SQL query. |
protected void |
tableChanged()
Notifies all listeners of changes. |
protected void |
trace(java.lang.String s)
Writes a trace line preceded by object identification. |
protected void |
update()
Returns the update count for an SQL statement. |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.Vector<java.util.Vector<java.lang.Object>> rows
protected java.lang.String[] names
protected java.sql.Connection conn
protected java.sql.DatabaseMetaData meta
protected java.sql.Statement stmt
protected java.sql.ResultSetMetaData md
protected java.sql.SQLException ex
Constructor Detail |
---|
public JdbcTable(java.lang.String driver)
driver
- the name of the JDBC driver.Method Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- if an error occurspublic java.lang.String getColumnName(int col)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
public java.lang.Class<?> getColumnClass(int col)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
public int getColumnCount()
public int getRowCount()
public java.lang.Object getValueAt(int r, int c)
public void connect(java.lang.String url, java.lang.String uid, java.lang.String pwd)
url
- identifies the database.uid
- user id.pwd
- password.public void execute(java.lang.String sql)
The result of the execution, whether it is a result set, updated count, or chain of exceptions, is returned in the JTable.
sql
- the SQL statement.public void getSchemas()
public void getTables(java.lang.String sp, java.lang.String tp)
sp
- schema name patterntp
- table name patternpublic void getColumns(java.lang.String sp, java.lang.String tp, java.lang.String cp)
sp
- schema name patterntp
- table name patterncp
- column name patternpublic void getProcedures(java.lang.String sp, java.lang.String tp)
sp
- schema name patterntp
- procedure name patternpublic void getProcedureColumns(java.lang.String sp, java.lang.String tp, java.lang.String cp)
sp
- schema name patterntp
- procedure name patterncp
- column name patternpublic void getPrimaryKeys(java.lang.String sp, java.lang.String tab)
sp
- schema nametab
- table namepublic void getExportedKeys(java.lang.String sp, java.lang.String tab)
sp
- schema nametab
- table namepublic void getImportedKeys(java.lang.String sp, java.lang.String tab)
sp
- schema nametab
- table namepublic void getCrossReference(java.lang.String pk_sp, java.lang.String pk_tab, java.lang.String fk_sp, java.lang.String fk_tab)
pk_sp
- primary key schema namepk_tab
- primary key table namefk_sp
- foreign key schema namefk_tab
- foreign key table namepublic void getBestRowIdentifier(java.lang.String sp, java.lang.String tab, boolean nullable)
sp
- schema nametab
- table namenullable
- true if including columns that are nullablepublic void getIndexInfo(java.lang.String sp, java.lang.String tab, boolean unique)
sp
- schema nametab
- table nameunique
- true if method to return only indices for unique valuesprotected void result(java.sql.ResultSet rs) throws java.sql.SQLException
Sets up the JTable with the values from the result set and its meta data.
java.sql.SQLException
- if an error occursprotected void update() throws java.sql.SQLException
java.sql.SQLException
- if an error occursprotected void error(java.sql.SQLException e)
e
- the SQLException.protected void error(java.lang.Exception e)
e
- the Exception.public void close()
public int getColumnWidth(int col)
protected void tableChanged()
protected void trace(java.lang.String s)
s
- String to write.protected void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |