Re: [INTERFACES] Java threads and the JDBC driver

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: [INTERFACES] Java threads and the JDBC driver
Date: 1998-09-14 18:15:24
Message-ID: Pine.LNX.3.96.980914190632.18301D-100000@maidast.retep.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Mon, 14 Sep 1998, Herouth Maoz wrote:

> As I understand it, the JDBC driver is not thread safe.
>
> I am trying to figure out how much synchronization I need.
>
> Is it safe to use separate ResultSets that originate from the same
> Connection object concurrently? That is, lock the connection object, create
> and perform the query into a new ResultSet, unlock the connection, and
> proceed to use the ResultSet? If I do that, other threads may be issuing
> queries while I'm still looping on the ResultSet.

As long as the query is done with a different Statement object, then in
theory yes. The api states that any existing ResultSet is closed when
executeQuery() or executeUpdate() is run, but you can have as many
Statement's as you want.

> It's supposed to be OK. But is it?

Now with our driver, all queries are actually done with the
Connection.ExecSQL() method.

Now that method is already syncronized, so it may work. I'll make up a
test, and see what happens.

--
Peter T Mount peter(at)retep(dot)org(dot)uk
Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgres
Java PDF Generator: http://www.retep.org.uk/pdf

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mikael Hammarin 1998-09-15 07:48:39 userid bug?
Previous Message Herouth Maoz 1998-09-14 13:05:16 Java threads and the JDBC driver