FreeTDS JDBC : Statements and transaction
mpeppler at peppler.org
Thu Aug 9 10:27:25 EDT 2001
Shinji Suzuki writes:
> I've noticed that using FreeTDS, Statements do not share transaction
> state even if they are from the same Connection. An example is;
> (1) createStatement from cx (stA = cx.createStatement())
> (2) createStatement from cx (stB = cx.createStatement())
> (3) set autocommit on cx (cx.setAutoCommit(true))
> (4) execute a sql command through stA (e.g. select * from intranet..cache)
> that will start transaction.
> (5) 'select @@trancount' through stA returns 1
> (6) but 'select @@trancount' through stB returns 0
My guess is that the JDBC driver does the same thing I do for
DBD::Sybase to support multiple statement handles on a single
connection handle - namely opening a new physical connection for the
second (and subsequent) statement handles.
It's nearly impossible to coordinate transactions over two separate
connections, so you should probably try to rework your code to avoid
having more than one statement handle open at a time.
Come to think of it - I'd be curious to know how jConnect does this...
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
mpeppler at peppler.org - mpeppler at mbay.net
International Sybase User Group - http://www.isug.com
More information about the FreeTDS