Re: Connection Pool Timeout - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Connection Pool Timeout
Date
Msg-id Pine.LNX.4.33.0401111639550.5953-100000@leary.csoft.net
Whole thread Raw
In response to Connection Pool Timeout  ("Neil Murray" <nhm@mimecast.net>)
Responses Re: Connection Pool Timeout  ("Marcus Andree S. Magalhaes" <marcus.magalhaes@vlinfo.com.br>)
List pgsql-jdbc

On Tue, 23 Dec 2003, Neil Murray wrote:

> Hi,
>
> I connect to the DB with pg73jdbc3.jar - and I make use of
> Jdbc3PoolingDataSource().
>
> Using the connection pool is no problem, but there seems to be a black hole
> of access at the point where the getConnection() method is called. If
> getConnection is called, and no DB connections are available, then
> getConnection() waits forever without throwing an exception. The API seems
> to indicate that there is a timeout that can be set, but setting it has made
> no difference. getConnection() still waits forever.

The setLoginTimeout method is just a stub and the comment for it indicates
that it is not implemented.  There are two issues with its implementation.
Regarding your problem that the pool is empty and it loops forever waiting
for a connection to be made available, it would be a pretty simple fix to
count the number of loops made and bail out once you've passed the
timeout.

The other problem is actually enforcing this connection timeout when
creating a real connection.  As far as I can see there is no means before
the 1.4 jvm to put a timeout value on creating a Socket connection.
Then for the whole connection and authentication process you would need to
call setSoTimeout on the Socket.  This would be incredibly ugly because to
enfore a setLoginTimeout of 4 seconds you couldn't simply use a 4 second
timeout on the socket's read and write calls because each one of many
could take 3.9 seconds.  You would have to continually monitor the time
elapsed and keep calling setSoTimeout with the remaing time left.

Kris Jurka



pgsql-jdbc by date:

Previous
From: "Marcus Andree S. Magalhaes"
Date:
Subject: Re: jdbc pooling question
Next
From: Kris Jurka
Date:
Subject: Re: jdbc pooling question