db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: SQLTransientConnectionException
Date Thu, 20 Nov 2008 09:37:31 GMT
Hi Björn,

Björn Bachman <bjorn.bachman@ericsson.com> writes:

> I have set #threads to 50

What exactly does that mean? Does it mean that you have set
derby.drda.maxThreads=50 on the server, or that you have 50 client
threads in your application?

> java.sql.SQLTransientConnectionException: java.net.BindException : Error
> connecting to server xxx.ericsson.se on port xxxx with message Address already
> in use: connect.
[...]
> Question is if I use derby correctly, loading it with thousands of
> simultaneous read calls from several clients.

I think the code looks correct. The BindException indicates that there
are no free ports on the client, probably because there are too many
open sockets. Since you say that you are closing your connections, my
guess is that either Derby or the OS is not freeing the sockets when the
connections are closed.

Are you by any chance using Windows? I think Windows by default has a
limited number of ports you can use, and it waits for some time (a
couple of minutes) after the socket is closed before it releases it. So
if you create thousands of connections in a short time, you will run out
of free ports. See this article in Microsoft Knowledge Base for details:
http://support.microsoft.com/kb/328476. The article talks about SQL
Server, but it should be valid for Derby as well.

Possible solutions include reusing connections instead of creating new
ones, or adjusting the MaxUserPort and TcpTimedWaitDelay registry
settings on the client machines.

-- 
Knut Anders

Mime
View raw message