This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC 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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
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 .
Similar Threads
Failure in running ear with EJB and Spring on clustered JBoss-5.1.0.GA AS
Update the whole info in database instead of one.
Updateable table of data from MySQL query
Entity Bean Problem
Updating Problem