Hello all,
I have used this code throughout this application with no troubles. I am creating a datatable, and the data is a result set returned from a sql query to an oracle 11g database. I'm creating a TableModel class that overrides the AbstractTableModel so I can add fetures to it. I get errors when I try to assign my ResultSet object however. Here is the code:
class MyTableModel extends AbstractTableModel {
Statement stmt = conn.createStatement();
ResultSet rs;
// the following throws compilation error: "cannot find symbol, symbol: class rs, location class <where it resides in my app> <identifier exepected>
rs = stmt.executeQuery(query);
//the following is fine:
ResultSetMetaData rsmd = rs.getMetaData();
int numcols = rsmd.getColumnCount();
int numrows;
int i = 0;
int k = 0;
//rs.next throws the same error as above
while (rs.next()) {
for (k = 0; k <= numcols; k++) {
data[i][k] = rs.getString(k);
}
if (checked) {
data[i][k + 1] = new Boolean(false);
}
i++;
}
//Default Table Model overrides follow.
I have no idea why this is not recognizing an object that was created in the line of code right above it, or why rs will auto complete with the expected methods and members but java can't find the package it belongs to.
rs hasn't been declared elsewhere. (It would throw a different error if it had). Any ideas?