Bug #16161 java.net.BindException: Address already in use
Submitted: 3 Jan 2006 18:42 Modified: 3 Jan 2006 18:54
Reporter: Mike Mike Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:4.1.15 OS:Windows (Windows 2003 Server x64)
Assigned to: CPU Architecture:Any

[3 Jan 2006 18:42] Mike Mike
Description:
Using Jconnector - mysql-connector-java-3.1.12-bin.jar

Java app using JDBC to MySQL DB.

I can not figure out why my application starts running fine and then it bombs.  The following error is in the application log:
************************************************
<Entry time="2005-12-23 14:11:54" level="SEVERE" class="com.saic.projectlewis.harvester.HarvesterLogger" method="exception" tid="47">com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.SocketException
MESSAGE: java.net.BindException: Address already in use: connect

STACKTRACE:

java.net.SocketException: java.net.BindException: Address already in use: connect
	at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
	at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
	at com.mysql.jdbc.Connection.createNewIO(Connection.java:2555)
	at com.mysql.jdbc.Connection.<init>(Connection.java:1485)
	at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at java.sql.DriverManager.getConnection(Unknown Source)
	at com.saic.projectlewis.harvester.DbConnector.getConnection(DbConnector.java:39)
	at com.saic.projectlewis.harvester.HarvesterToDb.checkHash(HarvesterToDb.java:307)
	at com.saic.projectlewis.harvester.HarvesterToDb.jobFileCollected(HarvesterToDb.java:246)
	at com.bat.harvester.ProcessorThread.a(Unknown Source)
	at com.bat.harvester.ProcessorThread.do(Unknown Source)
	at com.bat.harvester.ProcessorThread.run(Unknown Source)

** END NESTED EXCEPTION **

Last packet sent to the server was 0 ms ago.</Entry>

How to repeat:
Not sure how to explain.  I only get this problem when I run the Java application that connects to the MySQL DB.  Maybe the bug is in the COTs code?  They are telling me its a DB connectivity issue.

Basically this occurs everytime I run the application.
[3 Jan 2006 18:54] Mark Matthews
This only happens if the application opens more database connections than your operating system will support on the _client_ side. There are a fixed number of outbound ports that can be used for establishing TCP/IP connections, and they are only available for re-use after some timeout period (typically 15 minutes) after they've been closed.

It sounds like you have a misconfiguration with your application (or an architectural issue) that causes the application to open many hundreds of connections in a relatively short period of time.