Re: org.postgresql.Driver not thread-safe - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: org.postgresql.Driver not thread-safe
Date
Msg-id Pine.LNX.4.33.0311152014010.14784-200000@leary.csoft.net
Whole thread Raw
In response to org.postgresql.Driver not thread-safe  ("Karl von Randow" <karl@xk72.com>)
Responses Re: org.postgresql.Driver not thread-safe
List pgsql-jdbc

On Sun, 16 Nov 2003, Karl von Randow wrote:

> Hi all,
>
> It seems that org.postgresql.Driver isn't thread safe, as it stores details
> from the connection URL to the connect method in an instance variable
> "props" - and there is no synchronisation. The DriverManager
> (java.sql.DriverManager) returns the same instance of the
> org.postgresql.Driver to each getDriver(String url ) method and probably all
> of the others. Hence the problem with multiple threads connecting at the
> same time, the threads obtain the same Driver instance and the connection
> details from different threads can become muddled.

Yes, good catch.

> I've made a simple patch against the REL_7_3_STABLE branch of Driver.java.in
> which removes the use of the instance variable. I'm going to test this patch
> immediately.

In the future when submitting patches please use a context diff (-c)
format and attach it to the email so it avoids line wrapping.

Here is the corresponding patch against cvs tip which should also apply
cleanly to the 7.4 branch.

Kris Jurka


Attachment

pgsql-jdbc by date:

Previous
From: "Karl von Randow"
Date:
Subject: org.postgresql.Driver not thread-safe
Next
From: "Karl von Randow"
Date:
Subject: Re: org.postgresql.Driver not thread-safe