This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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!