You didn't specify how the code isn't working but one thing that catches eye is that you have two while loops where you advance in the result set
...
while (rs.next()) {
Object[] row = new Object[colcount];
for (int i = 1; i <= colcount; i++) {
row[i - 1] = rs.getObject(i);
}
tm.addRow(row);
}
while (rs.next()) {
}
jtable.setModel(tm);
...
Another thing is that
jtable
is not defined nor initialized in this code. Could it be uninitialized?