Our team is working on creating an Inventory Search application using SQL Anywhere as a database platform. The interface provides users a Table to view and query data consisting of some 1.2 million rows x 52 columns. My question pertains to the table implementation, specifically how to leverage the SQL Anywhere platform to avoid loading all 1 million + records into memory at once, i.e. how to accomplish a Record Set-Oriented, or asynchronous call implementation vice holding all records in memory. Below SAMPLE code provides an example of the latter, where JTable is filled (FillTable.setRS) into private ArrayList data;. In short, is there a less expensive means to create and fill the JTable than populating a massive ArrayList?
Sample Code:
public class FillTable extends AbstractTableModel {
/**
*
*/
private static final long serialVersionUID = -912060609250881296L;
private ResultSet rs;
private int rowCount;
private int columnCount;
private ArrayList data = new ArrayList();
public FillTable(ResultSet _rs) throws Exception {
setRS(_rs);
}
public void setRS(ResultSet _rs) throws Exception {
this.rs = _rs;
ResultSetMetaData metaData = _rs.getMetaData();
rowCount = 0;
columnCount = metaData.getColumnCount();
while (_rs.next()) {
Object[] row = new Object[columnCount];
for (int j = 0; j < columnCount; j++) {
row[j] = _rs.getObject(j + 1);
}
data.add(row);
rowCount++;
// if (rowCount > 175000)
// break;
}
}
public int getColumnCount() {
return columnCount;
}
public int getRowCount() {
return rowCount;
}
public Object getValueAt(int rowIndex, int columnIndex) {
Object[] row = (Object[]) data.get(rowIndex);
return row[columnIndex];
}
public String getColumnName(int columnIndex) {
try {
ResultSetMetaData metaData = rs.getMetaData();
return metaData.getColumnName(columnIndex + 1);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}

New Topic/Question
Reply



MultiQuote







|