Re: Strange exception opening JDBC connection - Mailing list pgsql-jdbc

From Jochem van Dieten
Subject Re: Strange exception opening JDBC connection
Date
Msg-id 3F0F2C4F.90404@oli.tudelft.nl
Whole thread Raw
In response to Strange exception opening JDBC connection  (Kevin Schmidt <kevin.schmidt@enterworks.com>)
List pgsql-jdbc
Kevin Schmidt wrote:
>
> java.net.BindException: Address already in use: connect
>    at java.net.PlainSocketImpl.socketConnect(Native Method)
>    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:295)
>    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:161)
>    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:148)
>    at java.net.Socket.connect(Socket.java:425)
>
>    at java.net.Socket.connect(Socket.java:375)
>    at java.net.Socket.<init>(Socket.java:290)
>    at java.net.Socket.<init>(Socket.java:118)
>    at org.postgresql.PG_Stream.<init>(PG_Stream.java:38)
>
>    at
> org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:154)
>    at org.postgresql.Driver.connect(Driver.java:120)
>    at java.sql.DriverManager.getConnection(DriverManager.java:512)
>    at java.sql.DriverManager.getConnection(DriverManager.java:171)
>
> Connections prior to this one have worked fine so the server is up and
> running, and it seems strange that an address already in use would
> happen when a client connection is made.  Any ideas what is going on?
> Does the JDBC driver try to listen on a port?

Possible explanation:
http://forum.java.sun.com/thread.jsp?thread=346820&forum=11&message=1434780

Microsoft documentation on the settings to change:
http://www.microsoft.com/windows2000/techinfo/howitworks/communications/networkbasics/tcpip_implement.asp
See "TCP TIME-WAIT Delay" on page 45 (but I would recommend reading it
all, it has a lot on hardening a Windows TCP/IP stack).

If this is caused by frequent connections to a PostgreSQL server (from
for instance a web application server) you might want to look into using
a connection pool :-)

Jochem




pgsql-jdbc by date:

Previous
From: Kim Ho
Date:
Subject: Patch to extend the tests for setObject with Date/Time/Timezone
Next
From: yphillips@dlkconsulting.co.za
Date:
Subject: Connection Pool