Hi all,
I am new to java and i am writing a program to obtain the column names
of a given table. When i run the program, i get all the table name into
a jList using DatabaseMetaData. What i want now is iwhen i click on a
tablename in the jList, i will like to obtain the columnNames of this
JList element(table) in another JList2.
Regards,
Matt Humphrey - 27 Nov 2005 14:38 GMT
> Hi all,
>
[quoted text clipped - 3 lines]
> tablename in the jList, i will like to obtain the columnNames of this
> JList element(table) in another JList2.
You have to do a query to get some kind of data back and the result set will
have the column names in the data. (E.g. select * from tablename)
ResultSetMetaData rsm = resultSet.getMetaData ();
for (int i = 1; i <= rsm.getColumnCount(); ++i) {
String columnName = rsm.getColumnName(i);
}
Check the API for additional methods.
Cheers,
Matt Humphrey matth@ivizNOSPAM.com http://www.iviz.com/
Chris Smith - 27 Nov 2005 15:03 GMT
> I am new to java and i am writing a program to obtain the column names
> of a given table. When i run the program, i get all the table name into
> a jList using DatabaseMetaData. What i want now is iwhen i click on a
> tablename in the jList, i will like to obtain the columnNames of this
> JList element(table) in another JList2.
Since you've already got a DatabaseMetaData, look up the getColumns
method. It will give you all the information you want. Matt's
suggestion will also work, but you'll get less information about the
columns and it's potentially very expensive.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation