Connection auto commit - No begin?

  • Thread starter =?ISO-8859-1?Q?Thomas_Gagn=E9?=
  • Start date
?

=?ISO-8859-1?Q?Thomas_Gagn=E9?=

In Sybase, if I want multiple statements to be part of a transaction I
can nestle them between BEGIN TRAN/COMMIT TRAN statements. reading
about JDBC's Connection objects I understand how auto commit works. But
I'm confused about the absense of a beginTran(). I suppose if
AutoCommit(false) then there's an assumed BEGIN at the start of my
statements that remains opened until I send either commit() or rollback()?
 
J

John C. Bollinger

Thomas said:
In Sybase, if I want multiple statements to be part of a transaction I
can nestle them between BEGIN TRAN/COMMIT TRAN statements. reading
about JDBC's Connection objects I understand how auto commit works. But
I'm confused about the absense of a beginTran(). I suppose if
AutoCommit(false) then there's an assumed BEGIN at the start of my
statements that remains opened until I send either commit() or rollback()?

The JDBC driver should handle the DBMS-side details of beginning and
ending transactions, transparently to you. Basically, yes, if you
setAutoCommit(false) on your connection, then you should expect a new
transaction to be started when the first statement is executed on that
connection after opening the connection or committing or rolling back a
transaction. The same transaction will remain open, as far as JDBC is
concerned, until you either commit() or rollback(), and all statements
executed on that connection will be part of it. If the DBMS and JDBC
run into a conflict with respect to transaction boundaries then you
should expect to receive an SQLException. If you want multiple
concurrent transactions you must have multiple connections.


John Bollinger
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top