This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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?
 
Don't get me started about those stupid light bulbs.
 
subject: Problem in using setValueAt() method - AbstractTableMethod.class
 
Similar Threads
JTable as User's input (?)
Problem in using setValueAt() method - AbstractTableMethod.class
Problem with setting the cell values in JTable
Refresh rows of a JTable
JTable, reloading the table...