开发者

(JPA/Toplink) Network error IOException: Address already in use: connect

I have a JPA project which used to work. This month, I have added some data in my database. When I run the usual job (I used to run on preceeding months), I get this error:

Exception [TOPLINK-4开发者_如何学JAVA002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Network error IOException: Address already in use: connect Error Code: 0

I checked on my LocalPersistenceFacade containing most methods I'm calling, by printing a counter, and I get the exact number of closed and opened connexions there: 457. And then my job crashes. Normally, It should go till 601 and not 457.

On database side, there is no information related to a possible crash. All seems to be correct, but my java code is saying something else.

Did someone have any idea please?

Regards, Jean


My understanding is that you are opening/closing a connection for each row and the problem you are facing looks like the one described in this page:

Possible Causes

When running large volume of data through maps that have multiple functions. Windows does not close connections fast enough which causes the Network I/O exception.

Recommendations

Modify the following two values in the Windows registry:

This one modifies the range of ports that Windows uses to open connections. By default it only allows up to the port 5000. By modifying this value, Windows will be able to open up more ports before having to recycle back to the beginning. Every connection uses a port, so it starts at 1025 and goes up to this value. When it reaches the max value it goes back to 1025 and tries to open up that port again.

System Key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Name: MaxUserPort Type: REG_DWORD
Value: 5000-65534

This will "release" closed ports faster. By default Windows leaves a port in a TIME_WAIT state for 240 seconds. This can cause problems if the MaxPort value is set to where a new connection will use an "older" port that has not been removed from TIME_WAIT state yet. By decreasing this value, you allow the connections to be released faster.

System Key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Value Name: TcpTimedWaitDelay Data
Type: REG_DWORD Value Data: 30-300

The symptoms and the change - more rows - introduced match perfectly. However, while the suggested "recommendation" may solve the problem, my recommendation would be use connection pooling (use a standalone connection pool like c3p0 or DBCP). This would IMO solve the problem and increase the performances.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜