Skip to Content.
Sympa Menu

freetds - RE: Transaction problems...

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Jeff Fisher <JFisher AT Emery-Waterhouse.com>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: RE: Transaction problems...
  • Date: Fri, 4 Jan 2002 15:35:01 -0500


What you need to do is use a prepared statement (assuming you're inserts are
the same).

You prepare you're statement once and simply continue to do inserts without
closing the statement. Once you are done, commit the changes and close the
statement.

-----Original Message-----
From: nnklak AT yahoo.com [mailto:nnklak AT yahoo.com]
Sent: Friday, January 04, 2002 2:51 PM
To: TDS Development Group
Subject: [freetds] RE: Transaction problems...


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

---
You are currently subscribed to freetds as: [jfisher AT emery-waterhouse.com]
To unsubscribe, forward this message to
$subst('Email.Unsub')




Archive powered by MHonArc 2.6.24.

Top of Page