adrianjohnson
Programmer
I've got some code which displays a list of database tables in a tree, and when a node is selected, the fields are listed underneath the table name.
I'd like to add the data type and size to the list of fields, so that it would read: field type size
Here's my code:
Variables colName, colType and colData are declared as strings, whereas colSize is an int.
When I run the code I get a "Column not found." If I remove all references to colSize (and COLUMN_SIZE) then it works and I get a list of tables.
Where am I going wrong?
(If I need to provide further code, let me know).
Thanks,
Adrian Johnson
I'm using Eclipse 3.1, with JRE 5.0 as my default, but also have 1.4.2 installed.
Adrian Johnson
Assystance - i.t. solutions
I'd like to add the data type and size to the list of fields, so that it would read: field type size
Here's my code:
Code:
// Get all the columns for the current table
ResultSet columnNames = metadata.getColumns(null, null, tableName, null);
// Add nodes for the columns as children of the table node
while(columnNames.next())
{
colName = columnNames.getString("COLUMN_NAME");
colType = columnNames.getString("DATA_TYPE");
colSize = columnNames.getInt("COLUMN_SIZE");
colData = colName + " " + colType + " " + colSize;
tableNode.add(new DefaultMutableTreeNode(colData));
}
Variables colName, colType and colData are declared as strings, whereas colSize is an int.
When I run the code I get a "Column not found." If I remove all references to colSize (and COLUMN_SIZE) then it works and I get a list of tables.
Where am I going wrong?
(If I need to provide further code, let me know).
Thanks,
Adrian Johnson
I'm using Eclipse 3.1, with JRE 5.0 as my default, but also have 1.4.2 installed.
Adrian Johnson
Assystance - i.t. solutions