Re: Strange exception opening JDBC connection

From: Jochem van Dieten <jochemd(at)oli(dot)tudelft(dot)nl>
To: Kevin Schmidt <kevin(dot)schmidt(at)enterworks(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Strange exception opening JDBC connection
Date: 2003-07-11 21:29:51
Message-ID: 3F0F2C4F.90404@oli.tudelft.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-jdbc by date

  From Date Subject
Next Message yphillips 2003-07-13 02:36:02 Connection Pool
Previous Message Kim Ho 2003-07-10 18:09:30 Patch: Add setDate/Time/Timestamp with Calendars