Hey,
I had the exact same problem. I found an answer here:
http://download.oracle.com/javase/tutorial/uiswing/components/table.html - Listening for Data Changes:
public class SimpleTableDemo ... implements TableModelListener {
...
public SimpleTableDemo() {
...
table.getModel().addTableModelListener(this);
...
}
public void tableChanged(TableModelEvent e) {
int row = e.getFirstRow();
int column = e.getColumn();
TableModel model = (TableModel)e.getSource();
String columnName = model.getColumnName(column);
Object data = model.getValueAt(row, column);
...// Do something with the data...
}
...
}
You can see which cell in your table has changed, so you can make a String containing a query for updating that database entry.
update TABLE set field= data (from the code quoted above) where id= model.getValueAt(X, Y);
X, Y = the row and column indexes where your ID is shown on the table.