I'm trying to design some java program that show content of MySQL database in JTable. I dont know what is better: to load whole table to a Vector, and then put data for each cell of table from it. Or load each cell as separate query?
public class DBTableMode extends AbstractTableModel {
...
Vector<Vector<Object>> data = dao.getWholeData(); //my getter of whole data table
...
public Object getValueAt(int rowIndex, int columnIndex) {
data.elementAt(rowIndex).elementAt(columnIndex);
}
...
OR
public class DBTableMode extends AbstractTableModel {
...
public Object getValueAt(int rowIndex, int columnIndex) {
dao.getCell(rowIndex, columnIndex);
}
...
Actually I don't know the operational principle of JTable, if it loads data onScrolling then second variant is much better. So, What is better in my case?