• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

JDBC Transaction Setting

Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();}

Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic