Trying to show a query from my DB in a jtable
hello
i have a query and i try to show it as a table in my gui
i did :
Code:
jTable1.setVisible(true);
try{
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","","");
Statement stmt= con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM lib.books_out");
JTable jTable1 =new JTable (DBUtils.resultSetToTableModel(rs));
}
catch(Exception e){System.out.println("Bad Connection"+e.getStackTrace());}
and debugged it the sql part is right and doesn't jump to exception
however the jtable is printed empty
any ideas ?
thanks to all the helpers
Re: Trying to show a query from my DB in a jtable
Solved
did
jTable1.setModel( DBUtils.resultSetToTableModel(rs)); in row 6