Subject Re: Transaction question
Author barroxfer
--- In Firebird-Java@yahoogroups.com, "Roman Rokytskyy" <rrokytskyy@a.
..> wrote:


> Hi,


>


> > I'm trying to create a transaction with this code:


> >


> > try


> > {


> > conex.getConnection().setAutoCommit(false);


> > conex.getConnection().createStatement().execute("set
transaction


> > name tr1 read committed");


> > ...


> > Can anybody guide me on how to begin-commit a transaction.


>


> Try to read JDBC tutorial. Transactions in JDBC are started


> automatically before the first statement is executed. Transaction do


> not have names and there can be only one transaction per connection.


> Transaction isolation level is set using


> Connection.setTransactionIsolation(int) method.




I've always used the commit method from connection, but in my
application I have 2 different threads importing data into firebird.
It will run over a slow network and I don't want one thread commiting
other's thread work. I found this message but doesn't work with
firebird:




Ben Starr wrote:


> Does JDBC support nested transactions?


Hi Ben, No it doesn't.


> From what I have seen there is no


> explicit statement to start a transaction, they just start from the
previous


> commit or rollback. I may be missing something but this seems to
make


> implementing nested transactions impossible.


More difficult, but not impossible. You can always revert to whatever
SQL


the DBMS supports, such as for Sybase You can do:


stmt.executeUpdate("BEGIN TRAN myTran");


stmt.executeUpdate("SAVE TRANSACTION");


etc.


Joe Weinstein at BEA, the home of WebLogic




Regards, Fernando.