aspose file tools*
The moose likes JDBC and the fly likes Problem in using setValueAt() method - AbstractTableMethod.class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Problem in using setValueAt() method - AbstractTableMethod.class" Watch "Problem in using setValueAt() method - AbstractTableMethod.class" New topic
Author

Problem in using setValueAt() method - AbstractTableMethod.class

Velika Srbija
Ranch Hand

Joined: Jan 15, 2002
Posts: 172
I've made my own implementation of setValueAt and isCellEditable methods (as well as other ones) in my TBLModel class that extends AbstracttableModel class.
Here are brief descriptions of the methods:
ResultSetMetaData metaData;
...
...
public boolean isCellEditable(int row, int col) {
if (metaData.getColumnName(col+1).equals("ID")) return false;
else return true;
}
public void setValueAt(Object value, int row, int col) {
int price = 0;
int id = 0;
...
//making changes in my data model - inserting new value in my row_vector etc.
...
...
//all of above code works fine
//
//problem begins here - when I try to update my hsql database
//example:
int no_update = statement.executeUpdate("update first_table set price="+price+" where ID="+id);
}
The problem with the above code is that after executing of setValueAt method, runtime calls isCellEditable method again. When it comes to the if statement java.lang.NullpointerException gets fired (though metadata is not null).
Note: If I remove the code in setValueAt method that updates my database, everything works OK. No Exceptions occures.
What is goin' on?
Why is method isCellEditable called again after executing of setValueAt method?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in using setValueAt() method - AbstractTableMethod.class