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 JDBC Transaction  Setting 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 "JDBC Transaction  Setting" Watch "JDBC Transaction  Setting" New topic

JDBC Transaction Setting

Gil Li

Joined: May 27, 2004
Posts: 15
hello people..
I wrote a java code to know the transaction process. I clearly set the
AutoCommit into false. Then I forcibly disable the commit just for checking purpose.
But the database changes whenevewr the statement executes. I have given below the code.
It should not update the database .But it does.I dont know where I am missing the technical things..
Please Help me...

import java.sql.*;
import java.util.*;

public class tranc
public static void main(String a[])

Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/tech?user=root&password=");


Statement st1=con.createStatement();
st1.executeUpdate("update topic_details set topic='ram' where tid=11");

Statement st2=con.createStatement();
st2.executeUpdate("update topic_details set topic='ram' where tid=9");


} catch(Exception e){ e.printStackTrace();}


Regards,<br /> <br />GILLI
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
I think the technical thing you're missing in this case is that most versions of MySQL don't support transactions. If you want transactions, use a proper database. (or read up about how to get or enable transaction support in MySQL)

I agree. Here's the link:
subject: JDBC Transaction Setting
jQuery in Action, 3rd edition