Re: Another exception (Transaction level)

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: Ole Streicher <ole-usenet-08(at)gmx(dot)net>
Cc: "pgsql-jdbc (at) postgresql (dot) org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Another exception (Transaction level)
Date: 2003-07-25 15:11:15
Message-ID: 20030725161115.G21371@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 |
+------------------------------+---------------------------------------------+

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Ole Streicher 2003-07-25 15:37:20 Re: Another exception (Transaction level)
Previous Message Tom Lane 2003-07-25 14:28:00 Re: Another LargeObject problem