Results 1 to 3 of 3
Thread: JTable and database
- 01-02-2009, 04:18 PM #1
Member
- Join Date
- Dec 2008
- Posts
- 28
- Rep Power
- 0
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! :)
- 03-09-2009, 09:12 PM #2
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
hello
just say hello
-
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
-
[SOLVED] How to load data from the database and display in jTable?
By tpyq in forum NetBeansReplies: 0Last Post: 12-04-2008, 05:39 PM -
Updating database table from JTable
By yesjava in forum New To JavaReplies: 1Last Post: 08-16-2008, 10:16 PM -
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05-15-2008, 10:15 AM -
Problem with jTable that is binded with a table in MySQL Database
By rajkenneth in forum NetBeansReplies: 0Last Post: 03-29-2008, 03:36 PM -
Help with JTable
By fernando in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks