I've tried even using:
public void doDelete(){
int i = 0;
int r = 0;
while (i < 600) {
jTable1.remove(r);
r++;i++;
}
doRefresh();
}
public void doRefresh(){
try {
String url = "jdbc:odbc:dts";
String user = "";
String password = "";
Connection con = DriverManager.getConnection(url, user, password);
String getCust = "SELECT * FROM Customer";
PreparedStatement ps = con.prepareStatement(getCust);
ResultSet rs = ps.executeQuery();
while (rs.next()){
String s = rs.getString(1);
jTable1.setValueAt(s, R, 0);
s = rs.getString(2);
jTable1.setValueAt(s, R, 1);
s = rs.getString(3);
jTable1.setValueAt(s, R, 2);
s = rs.getString(4);
jTable1.setValueAt(s, R, 3);
s = rs.getString(5);
jTable1.setValueAt(s, R, 4);
s = rs.getString(6);
jTable1.setValueAt(s, R, 5);
s = rs.getString(7);
jTable1.setValueAt(s, R, 6);
s = rs.getString(8);
jTable1.setValueAt(s, R, 7);
R++;
}
} catch (Exception e) {
lblConnect.setText("Error in doRefresh()");
}
}
and it doesn't work really.
The "Delete" button will delete the info from the database properly (won't reflect changes to the jTable though) then you press the "Refresh" button and all of instead of the entire jTable being deleted and re-populated, it just appends the new database (minus the row you selected to be deleted)