• Post Reply Bookmark Topic Watch Topic
  • New Topic

update statement?  RSS feed

 
nadine nicole
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have a question...
i use Eclipse but i'm not very advanced in java...
i wrote a sql statement in java by doing this :
and the above sql statement worked perfectly

but i want to do the same with an update sql statement, so here is what i want to do: I have a JTable(the one that the user can edit, and i want each time the user clicks on the jtable ( i can display the table and it's editable and it is changed...) i want the changes to be editable in the database itself.....so here is what i have in mind:



I want to set the string i enter in the text field to be the string in the place of the original string that is already in the table...i have 4 columns...1st one is student id, then the name, then the major , then the year graduated...
for example: if he changed the id of the student called steven from 1 to 6...so i want the 6 to be in the place of the 1 and i want the change to be in the database too and not only on the table....
help?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TableModelListener
 
Janeice DelVecchio
Bartender
Posts: 1810
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to Java Ranch!
 
Campbell Ritchie
Sheriff
Posts: 53774
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like something which would sit better on our GUIs forum. Moving thread.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like a SQL question.
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's both.

Nadine, check out how JDBC works for the database updating. The biggest issue is matching table rows with database records. I think you will need a unique field or unique group of fields to represent each record. That field / those fields should be present in the model too; you can hide them from the table by removing table columns if you do not want to show them.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!