Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to save the changes in db through JTable  RSS feed

 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have a JTable with 100 or more rows. What i need is that the user should select the row and click the button delete. Then the row from database must also be deleted. One more thing i want to know is that how can i save the changes made in JTable in the database. I need a little help.



Thanks and Regards
alexander
 
K. Tsang
Bartender
Posts: 3630
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Adeeb,

Are you using a cache (memory) of the data? If so, when you click delete button, you trigger the table model to remove that row or object from the data. At the same time, the table model through some means delete the physical database table row then fireXXX() methods.

If no cache, then the table model deletes the physical database table row and refresh the view using fireXXX() methods.

Of course you would need a action listener for the delete button to trigger the appropriate method in the table model.

All this depends on where you are doing the actual modification, backend (some service layer between db and client) or directly in the table model class (front end).
 
adeeb alexander
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tsang.
I am using just the default table model. just like this



Now where and what should i change or add to get the work done.

Thanks.>
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!