Results 1 to 2 of 2
  1. #1
    java_begin is offline Member
    Join Date
    Jan 2013
    Posts
    1
    Rep Power
    0

    Default populating jtable from database

    I am trying to fill a jTable from a resultset, but when I try to add it it asks for a TableModel and not a resultset.

    Java Code:
    DBConnect dbSample = new DBConnect ("NAMES");
             jTable1.setModel(dbSample.getDetails());
    Java Code:
    public ResultSet getDetails () throws SQLException
          {
             Statement stmt = conn.createStatement ();
             ResultSet rs = stmt.executeQuery ("SELECT * FROM DETAILS");
         
             stmt.close ();
             return rs;
          }
    Do I need to convert the resultset into a TableModel? If so how does one do this?

  2. #2
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Location
    Belgrade, Serbia
    Posts
    291
    Rep Power
    4

Similar Threads

  1. Replies: 2
    Last Post: 05-07-2011, 06:32 PM
  2. Jtable cells not populating correctly
    By wlc in forum AWT / Swing
    Replies: 2
    Last Post: 04-04-2011, 05:57 AM
  3. Populating Jtable from database - better way?
    By madhura2212 in forum AWT / Swing
    Replies: 5
    Last Post: 10-05-2010, 02:04 PM
  4. Populating JTable with 2 arrays (Netbeans)
    By althair in forum AWT / Swing
    Replies: 3
    Last Post: 12-30-2009, 02:05 PM
  5. Populating a JTable
    By toymachiner62 in forum New To Java
    Replies: 2
    Last Post: 10-13-2009, 05:56 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
  •