Updating database from jtable
I dont know how to catch the event..where.true sense I am stuck here..... Model()Table Model Listener(your Class); And in the class that you decide will implement the Table Model Listener you need this So that's the first part of it. Cheers, Rachel [ July 27, 2004: Message edited by: Rachel Swailes ] [ July 27, 2004: Message edited by: Rachel Swailes ] Hi rachel, Thanks for your inputs wihtout which I wud still have been stuck.
I am able to listen to the event and get changed values.
I found some of the examples what other people did but they did not work for me. If any one need a code of the methods I use to get data from the Database I will be happily to post them.
So my question is this: Does it matter how you getting and storing data from the Database?? I know about different methods that can be used to do it but I don't know which is one is better be useful for my situation. method, which would allow you to not only update the state of the model, but also update the state of the database (I'd update the database and when successful, update the model, but that's me) OR attach a listener to the model and monitor for approriate events and update the database accordingly.
Cheers, Rachel Hi Rachel, You are really helping me a lot. Cheers, Rachel Hi Rachel, I am working on the problem which i said above. I will give my update, immediately i complete my task. Sometimes I tend to get ahead of myself when explaining.
I have found the same problem posted by some other person and you have replied it. Thanking you, Agatha.i tested the code i posted and it worked perfectly but people on sun forums says that it's such a bad behaviour to mix the ui and the database,and there's no object oriented here??? You want to get the logic for updating the database (in MVC, the "C") a long way away from the display (the "V") because the two perform different things, and it allows easy maintenance if the two are well separated. Step 1: It's going to be way easier for the whole thing if you make your table extend a Table Model from now (if you haven't already). Step 2: In the table model you need to enable the cells to be editable.
1 then the database is upodated with particular value, why is this happening please help.
My code for refresh Button goes like this: int pos = record Selected Row(); int id = (Integer) record Model()Value At(pos, 0); List Selection Model selection Model = record Selection Model(); selection Selection Interval(pos, pos); String room Name = (String) record Value At(pos, 1); int room Charge = Integer.parse Int(record Model()Value At(pos, 2)String()); println(id room Name room Charge); record Table.revalidate(); record Table.repaint(); admin.update Room Type(id, room Name, room Charge); Are you sure about the database update?
Is it possible to restrict the user..achieving this?? Thanks & Bye, Agatha Hi rachel, Thanks for your inputs without which I wud still have been stuck.
my table looks like When i edit the value in particular cell and without clicking anywhere if i click on Update button the database is not updated as like this !
but if i click somewhere in the updating row, which again turns the look of table as fig.
Don't forget to post your SSCCE in the new mahmoud saleh , I tried to run your code with some modification according to my database but it gives me Class Lang.exception on this line:
I am trying to update database by editing cell values in jtable.