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

    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";
            try{
            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
    Posts
    11,438
    Rep Power
    18

    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.

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

    Default Re: From query to JTable

    Crossposted: From query to JTable
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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
  •