This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes populating 2-D array dynamically with JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "populating 2-D array dynamically with JTable" Watch "populating 2-D array dynamically with JTable" New topic

populating 2-D array dynamically with JTable

sand maverick

Joined: Nov 15, 2009
Posts: 2
hiiii........i want to populate a 2-D array using database which will be shown in a swing application using JTable.....i am not getting able to populate 2-d array there any method like fill() for this purpose....
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2296
Well, you should not be using a 2D array for this purpose. You don't know how many rows are in your database so you don't know how big to make the array.

Instead you should be using a Vector of Vectors. The main Vector is used to hold the rows of data. Then for each row in the ResultSet you create another Vector and get all the value for that row. Then you add the row vector to the main vector.
I agree. Here's the link:
subject: populating 2-D array dynamically with JTable