Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting column names from JDBC and display it in JTree  RSS feed

 
Ruel Soriano
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
greetings, could someone send me simple code on how to get the column names from table and display it in JTree format. I have two table maintenace and report, the node name would be the two table name and its child would be its corresponding column name and child for column would be its value or element....please someone help me for this...
thank you very much.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Supplying code is not what this site is for (see this). However we can get you started by suggesting you look as the class java.sql.ResultSetMetaData.
 
Ruel Soriano
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for that, but i could not start what i'm doing coz i dont have any idea and can't of one, well i know how to use ResultSetMetaData and displaying the column but my big problem is how can i make a child of each...for example

Table [table_1] with column [column_1 column_2 column_3]
Table [table_2] with column [col1 col2 col3]

how can i make them to display in JTree like:

table_1
|
|-----------column_1
|-----------column_2
|-----------column_3
table_2
|
|------------col1
|------------col2
|------------col3

could someone give me an idea or better a sample code for this....
thanks in advance.....
 
Jan Cumps
Bartender
Posts: 2632
17
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Better ask that question in the Swing / AWT / SWT / JFace forum.

Regards, Jan
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
 
Ruel Soriano
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if i can get some code or extract a code just to be my guide......i know how to get the column name from and extract it to jtree but my problem is how if one of my column has a child, automatically it add on the last column name i created.
for example col_1, col_2, col_3 will be the node for root, what if i have a child for for each of the column, all of them will be in the last column like col_3.......

so please give a solution for this.....urgent.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!