Results 1 to 2 of 2
  1. #1
    smacker is offline Member
    Join Date
    Jan 2011
    Posts
    46
    Rep Power
    0

    Default 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 :
    Java 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

  2. #2
    smacker is offline Member
    Join Date
    Jan 2011
    Posts
    46
    Rep Power
    0

    Default Re: Trying to show a query from my DB in a jtable

    Solved

    did
    jTable1.setModel( DBUtils.resultSetToTableModel(rs)); in row 6

Similar Threads

  1. From query to JTable
    By drimades in forum JDBC
    Replies: 2
    Last Post: 03-07-2012, 05:43 PM
  2. Using jTable to display query result
    By zenith666 in forum New To Java
    Replies: 2
    Last Post: 01-13-2012, 03:29 AM
  3. JTable Query
    By Siddharth Singh in forum AWT / Swing
    Replies: 1
    Last Post: 01-11-2012, 04:36 PM
  4. JTable doesnt show columun names!
    By phil128 in forum AWT / Swing
    Replies: 3
    Last Post: 03-08-2009, 11:39 PM
  5. netbeans 6.0 not show commpunent or show blank page
    By fahimaamir in forum NetBeans
    Replies: 1
    Last Post: 01-26-2008, 07:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •