Although you do increment the row number at the end you've declared it as a local variable which loses its value and gets initialized to 0 at every method call. Hence your first row gets overwritten everytime.
int row = 0; // move this out to a member variable
String st= JcbSub.getSelectedItem().toString();
jTable3.setValueAt(st, row, 0);
row ++; // this increment currently has no effect on next method call
You're also opening a new database connection every time and not closing it by calling con.close()
. In fact, since you're not executing any queries via your Statement
object stmt there's no need for all the JDBC code inside the method.