Re: Another exception (Transaction level) - Mailing list pgsql-jdbc

From Paul Thomas
Subject Re: Another exception (Transaction level)
Date
Msg-id 20030725161115.G21371@bacon
Whole thread Raw
In response to Re: Another exception (Transaction level)  (Ole Streicher <ole-usenet-spam@gmx.net>)
Responses Re: Another exception (Transaction level)
List pgsql-jdbc
On 25/07/2003 15:15 Ole Streicher wrote:
> Hello Paul!
>
> Paul Thomas writes:
>  > > Connection dbConn;
>  > > dbConn = java.sql.DriverManager.getConnection(...);
>  > >
> dbConn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
>  > > dbConn.setAutoCommit(false);
>  > > and then I use this instance of dbConn for querys and updates (which
>  > > may occur concurrently at the same time).
>  > Concurrently? Do you mean that you a sharing one connection between
>  > several threads?
>
> Yes. I didn't see a hint why this should be problematic.

You _might_ be ok if you were just doing selects (I've never tried it so
I'm just guessing here) but for inserts/updates/deletes with transactions,
you are going to run into problems because you commit/rollback on the
connection and I suspect that the back-end will only allow one active
transaction at a time.

>
>  > If so then that may be the cause of your problems.
>
> How can I avoid this? Shall I establish a new connection for every
> asynchronious request/update I have? Aren't they expensive?

As Csaba has already suggested, use a connection pool.

>
>  > > Finally, I found out the same when searching the net. But, why the
>  > > user's manual (9.2. "Transaction Isolation") states something
>  > > different? I guess it should be corrected in the manual.
>  > FWIW, the 7.3.3 docs only mention supporting read committed and
>  > serialized. Which version are you using?
>
> 7.2.2 from SuSE, but my pdf documentation is of 7.3.2 (downloaded
> wednesday or so). Page 141 (a4 version): "The four transaction levels
> and the corresponding behavior are shown in Table 9-1".

Those are defined behaviours of the SQL spec. The sentance just below
table 9-1 is the important one ;-)

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

pgsql-jdbc by date:

Previous
From: Tom Lane
Date:
Subject: Re: Another LargeObject problem
Next
From: Ole Streicher
Date:
Subject: Re: Another exception (Transaction level)