Skip to Content.
Sympa Menu

freetds - RE: Transaction problems...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: nnklak AT yahoo.com
  • To: freetds AT franklin.oit.unc.edu
  • Subject: RE: Transaction problems...
  • Date: Fri, 4 Jan 2002 14:51:27 -0500


Hi, I am facing a similar problem, the question is:

Why the following code does NOT work (no inserts in the DB)
Connection.setAutoCommit(false);
Statement stInsertSQL = Connection.createStatement();
stInsertSQL.execute("INSERT INTO table1 values(1,2)");
st.close();
Connection.commit();
Connection.setAutoCommit(true);
Connection.close();

While the following code seems to work:
Connection.setAutoCommit(false);
Statement stInsertSQL = Connection.createStatement();
stInsertSQL.execute("INSERT INTO table1 values(1,2)");
//st.close();
Connection.commit();
st.close();
Connection.setAutoCommit(true);
Connection.close();

I have to insert 500 rows in the DB as a transaction; Do I have to keep
500 Statement variables until the Connection.commit()statement ?

Thanks
- Nikolas




Archive powered by MHonArc 2.6.24.

Top of Page