Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and the fly likes how to display the resultset into the JTabel ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to display the resultset into the JTabel ?" Watch "how to display the resultset into the JTabel ?" New topic
Author

how to display the resultset into the JTabel ?

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

hi
i know that to display data in Jtable is like

but my problem arises when i want to pull the data from the database and used it in the Jtable's constructor i mean
i know that the result of the sql quary "select * from emp" gives me all the data in that table which is holded by Result rs ....
now my question is how i can use this rs which contain my data of table emp so that i will be able to see my data in the JTabel ?
i have done my homework by asking "google" but unfortunately he is not able to help me , so if you experience guyz can show me this thing with a help of a simple example that will be great !

The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Minh Nam
Ranch Hand

Joined: Sep 10, 2011
Posts: 57
Well, a simple way is to iterate over the result to build the vector of data which is passed into table's constructor:



However I suggest you to use a table model to store table data, something like this:



Advanced java topics
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to display the resultset into the JTabel ?
 
Similar Threads
JTree + JTabel
JSpinner Percentage editor as JTabel CellEditor
Jtabel
JTabel
Displaying the Column Name for JTabel