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 Problem in updating a table . 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 "Problem in updating a table ." Watch "Problem in updating a table ." New topic

Problem in updating a table .

Ganesh Chandrasekaran

Joined: Nov 14, 2000
Posts: 22
Hi Ranchers,

We have a problem in updating a table in MySQL.

the query used is
String sqlUpdateStatus = "UPDATE candidate_login_tbl SET "+
" candidate_login_status ='l', "+
" candidate_last_login_date ='"+ dt +
"' where candidate_id = "+ candidateID +";";

stmt3 = conn.createStatement();

when run It doesn't give any error but at the same time does not update
the table.
Also if i copy the print out put and run it directly in the mySQL query browser the table gets updated.

Can some one help me out.

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367

Try removing the date. Is it a datetime in the database. Does
it look ok. Try using


}catch( Exception e ){

Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
You need to explicitly call conn.commit() after the update(s) or set the auto-commit property of the connection to true.

Otherwise the sql will be applied but rolled back once the connection is closed.
Ganesh Chandrasekaran

Joined: Nov 14, 2000
Posts: 22

Thanks Mathias Nilsson
Thanks Scott Johnson

When i added conn.commit(), it worked.

Thank you very much.
I agree. Here's the link:
subject: Problem in updating a table .
It's not a secret anymore!