File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT / JFace and the fly likes update statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT / JFace
Reply Bookmark "update statement?" Watch "update statement?" New topic
Author

update statement?

nadine nicole
Greenhorn

Joined: Mar 16, 2010
Posts: 1
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

Joined: May 03, 2008
Posts: 2516

TableModelListener



luck, db
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1557

And welcome to Java Ranch!


When you do things right, people won't be sure you've done anything at all.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 25060
Sounds like something which would sit better on our GUIs forum. Moving thread.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12612
Sounds like a SQL question.
Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 17259

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
 
subject: update statement?
 
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com