Results 1 to 3 of 3
  1. #1
    drimades is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default From query to JTable

    In Netbeans I'm using a JTable to display data from a db table. How can I bind the JTable to the results of a query (resultset)?

    Here is how I create the recordset:

    Java Code:
    String host = "jdbc:derby://localhost:1527/TownHall";
            String uName = "test";
            String uPass= "111";
            Connection con = DriverManager.getConnection( host, uName, uPass );
            Statement stmt = con.createStatement( );
            String SQL = "SELECT * FROM TAXES";
            ResultSet rs = stmt.executeQuery( SQL );
    Last edited by drimades; 03-07-2012 at 03:59 PM.

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: From query to JTable

    I'd (personally) stick them in a model.
    Return a List<YourModel>, and probably produce a TableModel to give to the JTable.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

Similar Threads

  1. Using jTable to display query result
    By zenith666 in forum New To Java
    Replies: 2
    Last Post: 01-13-2012, 02:29 AM
  2. JTable Query
    By Siddharth Singh in forum AWT / Swing
    Replies: 1
    Last Post: 01-11-2012, 03:36 PM
  3. need sql query
    By murali23krishna in forum JDBC
    Replies: 8
    Last Post: 05-17-2011, 11:42 AM
  4. Adding New JTable in JTable
    By anilkumar_vist in forum New To Java
    Replies: 0
    Last Post: 01-27-2010, 08:27 AM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 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