Most recently, using the JDBC Operations database with multithreading under Windows, the number of threads is set to 5, and after each thread completes sleep (1000), in this case, the error is also:
Java.net.SocketException No buffer space available (maximum connections reached) Jvm_bind
A look at this type of error, should belong to the socket connection is not closed or waiting, because I use JDBC to operate the database, and is a short connection form, that is, each time an operation to create a new JDBC connection, the operation is completed to close the JDBC connection, The JDBC connection is based on the socket, then the problem should appear on the JDBC Connection database, plus I use the original script written by the Java program, and no framework and the Web container, so there is no JDBC connection pool to help me control the JDBC connection shutdown. After a variety of attempts and Google, it is possible that the Windows system-level socket settings are the cause.
The solution is as follows:
1. Start Registry Editor. Hkey_local_machine/system/currentcontrolset/services/tcpip/parameters
2. New
Value Name: MaxUserPort
Value type: DWORD
Value data: 65534 (decimal)
Valid range: 5000-65534 (decimal)
Default: 0x1388 5000 (decimal)
New
Value Name: TcpTimedWaitDelay
Value type: DWORD
Value data: 30 (this represents the number of seconds time_wait)
The most important of these is tcptimedwaitdelay, if a socket connection waits longer than 30 seconds, the connection is closed.
Run the program again, and now set the number of threads to 30, and the program will still work.
Windows under Socket link overflow