• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in using setValueAt() method - AbstractTableMethod.class

 
Ranch Hand
Posts: 172
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic