This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes jtree and database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jtree and database" Watch "jtree and database" New topic
Author

jtree and database

jb er
Greenhorn

Joined: May 02, 2003
Posts: 3
Hi,
I have not used jtree before and I am trying to make one which represents the database. I know that the root will be the database name. children will be tablenames and grandchildren will be column or field names. I also understood how tree is created etc...
My question is how do I get the colum/field names? Is there a method like say getcolumnname or so.. Same problem with tablenames. Are there any examples i could take a look. All the examples I saw deal with file explorer.
Help,
J
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1132

Hi J,
how do I get the colum/field names?

Pardon me, but is the "DatabaseMetaData" interface not suitable?
http://java.sun.com/j2se/1.4.1/docs/api/java/sql/DatabaseMetaData.html
Hope it helps.
Good Luck,
Avi.
jb er
Greenhorn

Joined: May 02, 2003
Posts: 3
Thanks, I know how to get the columns for each table, using ResultMetaData.
But am still confused on how to get just the table names.
I checked your link, but am not so good at DB. So am confused as to which one to use... to get just the tableNames.
Thanks,
J
Naveen Asha
Greenhorn

Joined: Mar 30, 2003
Posts: 12
There is method in ResultSetMetaData to get table name.
ResultSetMetaData.getCatalogName(int)
Naveen Asha
Greenhorn

Joined: Mar 30, 2003
Posts: 12
Sorry, it is getTableName(int)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jtree and database