Hi All,
I have a Jtable with six columns. I am displaying the contents of my database into my Jtable. Its working fine.
But I am facing trouble updating the changes done in Jtable cells to appropriate database cell.
In the below code when I tried to edit the First Row ,third column in my Jtable, it does not get reflected in the First row, third column in my database, Indeed im getting an error "Column count doesn't match value count at row 1".
Here is my code which I created the JTable using defaultTable Model.
Thanks in Advance.
public void tableChanged(TableModelEvent e) {
// TODO Auto-generated method stub
if(e.getType()==TableModelEvent.UPDATE){
Object value = dm.getValueAt(e.getFirstRow(), e.getColumn());
try {
statement =(Statement) dbConnection.createStatement();
int count = statement.executeUpdate ("INSERT INTO incident VALUES ('"+value+"')");
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}