Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtree and database

 
jb er
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is method in ResultSetMetaData to get table name.
ResultSetMetaData.getCatalogName(int)
 
Naveen Asha
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, it is getTableName(int)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic