Results 1 to 3 of 3
  1. #1
    hendrix79 is offline Member
    Join Date
    Dec 2008
    Rep Power

    Default JTable and database

    Hello folks!

    I have a question: i premise that i've already searched in the forum.
    I have a JTable, created on my own TableModel. I can't post any code because i'm not at home and i need to urgently reach a solution, so here i am. I know that JTable works this way:

    JTable accept these parameters: String[][] (which is the matrix that contains data) and String[] (which contains column names).
    I need to populate the JTable from values coming from the database. Ok, i've got the query running good and the correct resultset that gives me the data i need. The question is: how can i fill the matrix String[][] (the first parameter of the JTable)? I have to create a 'for' iteration? Or can i fill the matrix in the 'while' iteration from the resultset? I tried in a lot of ways, but i can only print the last of the resultset.

    Thanks a lot in advance!

    Ps: Happy new year to everyone! :)

  2. #2
    kamol is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default hello

    just say hello

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    First off, I would extend a DefaultTableModel object as my table model, and then I'd use its addRow(...) method to add information to the table when / if it becomes available. So the key is that you're adding information to the model not the table, and you're using a Model object that has methods that will accept a new row.

Similar Threads

  1. Replies: 0
    Last Post: 12-04-2008, 05:39 PM
  2. Updating database table from JTable
    By yesjava in forum New To Java
    Replies: 1
    Last Post: 08-16-2008, 10:16 PM
  3. Replies: 2
    Last Post: 05-15-2008, 10:15 AM
  4. Replies: 0
    Last Post: 03-29-2008, 03:36 PM
  5. Help with JTable
    By fernando in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 06:57 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