File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Update Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Update" Watch "Update" New topic


Manuel Paco
Ranch Hand

Joined: Sep 23, 2001
Posts: 58
Would you help me please find what is wrong with that?

query = "UPDATE caregiver SET" +
"(sex, firstname, lastname)" +
" VALUES(?,?,?)" +
" WHERE id = ?";
PreparedStatement preparedStatement= databaseConnection.prepareStatement( query );
preparedStatement.setString( 1,;
preparedStatement.setString( 2, fields.firstName.getText() );
preparedStatement.setString( 3, fields.lastName.getText() );
preparedStatement.setString( 4, );

result = preparedStatement.executeUpdate();
Claudio Gualberto
Ranch Hand

Joined: Oct 13, 2002
Posts: 47
Nothing is wrong to me. You better post the error message from the SQLException it's generating, thus we can help you easer.
Claudio Gualberto.
Manuel Paco
Ranch Hand

Joined: Sep 23, 2001
Posts: 58
I got General error
sandesh bangera

Joined: Nov 13, 2002
Posts: 12
Assuming you are usnig Oracle, then the update syntax is wrong.
sql> update <tablename> set
column1 = <updatedvalue>,
column2 = <updatedvalue>
where <condition>
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

I agree with Sandesh, except for all databases, not just Oracle.
I agree. Here's the link:
subject: Update
It's not a secret anymore!