
Originally Posted by
Patel [email
Amit@nabble.com[/email]]It looks like you are not using a connection pool. By not using a connection pool, each time you need a connection, your app will need to spend the overhead of pening the socket connection to the db server.
Your netstat -a shows that all your connections are in TIME_WAIT status, which means the connection has been closed and is waiting for the OS to release the resources. If you are running on Windows, the default ephemeral port rang is between 1024 and 5000 and the default time it takes windows to release the resource from TIME_WAIT status is 4 minutes. So if your application used more then 3976 connections in less then 4 minutes, you will get the exception below.
Some suggestions to fix this:
1) Add a connection pool (check out Apache dbcp). This will reduce the number of connections to the db and speed up your application.
2) Change your windows settings to allow for more ephemeral ports and a quicker close time. This can be done by modifying the following registry settings:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Servic es\Tcpip\Parameters:
MaxUserPort = dword:00004e20 (20,000 decimal)
TcpTimedWaitDelay = dword:0000001e (30 decimal)