how to print a resultset in a jtable..

I have retreived the data set and I want it to desplay in a table as it is in the database. How can i achieve it?

thnakx.

Read the result into a two-dimensional array and then use

((DefaultTableModel) jTable.getModel()).setDataVector(<2darray>, <columnNames>);
jTable.repaint();

Edit: P.S. Since you cannot, reliably, know, beforehand (without some futzing around), how many rows the resultset contains read it into a List<String[]> and then use List's toArray method to get the List as an array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.