Re: BindException (Address already in use) when connecting to MSSQL
From: John C. Bollinger (jobollin_at_indiana.edu)
Date: 07/06/04
- Next message: Steve Nakhla: "MS Outlook plugins in Java?"
- Previous message: Tomer Ben-David: "i know its been delt but i must ask jsf vs struts"
- In reply to: Tage V. Madsen: "BindException (Address already in use) when connecting to MSSQL"
- Next in thread: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Reply: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Reply: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 06 Jul 2004 13:37:22 -0500
Tage V. Madsen wrote:
> I'm experiencing a problem with JDBC and MSSQL 2000, now and again
> DriverManager.getConnection() throws a java.net.BindException, with
> this message:
>
> TCP/IP connection failed to host:java.net.BindException: Address
> already in use: connect
> url:jdbc:JSQLConnect://localhost:1433/database=DBx/
>
> I've boiled the problem down to an example - listed below, after
> connecting approx. 3960 times the exception is thrown - on my 3 Ghz
> PC, on slower ones it works, so it must be timing-related...
If the diagnostic message is to be accepted as a reasonably accurate
description of the failure then it would seem to indicate a problem in
the driver, Java class library, or in Windows network stack. However,
it may well be that it is a problem that is not triggered in reasonable
use scenarios. Your code creates many connections to the same local
address and closes them again, all as fast as it can. This does not
model any reasonable use scenario; indeed if it persisted long enough
this test would constitute a DOS attack.
My best guess is that you are running into a system limit on the number
of open file descriptors. Invoking close() on your Connections will
cause their sockets to eventually be closed, but it may not force them
to close immediately. This would be a performance feature. However, if
you keep opening new sockets without giving the existing, no longer
needed ones a chance to close then you will eventually run into a file
descriptor limit.
> To verify that MSSQL is working, I've created a similar app in
> VC++/ODBC, and there it works fine - I can connect 100000 times
> without problems.
That's nice, but not very relevant.
> I'm using JNetDirect's JDBC driver, but I've also tried the MS driver,
> same behaviour. The use of DriverManager instead of a (pooled)
> DataSource is merely for simplicity, the behaviour is, again, the
> same, either way.
I don't believe that you will see this behavior with a DataSource that
actually uses a connection pool if you ensure that the pool has a
reasonable maximum size. Indeed, even a size cap oughtn't to be
necessary in the single-threaded test scenario you present. Beware,
however, of DataSource implementations that may just wrap DriverManager
without providing pooling. Don't assume that a DataSource automatically
uses a pool.
John Bollinger
jobollin@indiana.edu
- Next message: Steve Nakhla: "MS Outlook plugins in Java?"
- Previous message: Tomer Ben-David: "i know its been delt but i must ask jsf vs struts"
- In reply to: Tage V. Madsen: "BindException (Address already in use) when connecting to MSSQL"
- Next in thread: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Reply: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Reply: Tage V. Madsen: "Re: BindException (Address already in use) when connecting to MSSQL"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|