Hi, i want to test a program that requests to a servlet continuously, then save the response to SQL (SQL Server 2000) database. But there is a problem.
After a while the program starts, it throws an exception and becomes throwing the same exception at each http request. I dont understand why?
I'm releasing the connection but it can not connect anymore...???
I had many change on the code, but it did not work.
The code for testing is :
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
public class StressTest {
public static void main(String[] args) {
while(true) {
PostMethod post = new PostMethod("http://localhost:8080/cepkisit/cepkisit");
HttpClient client = new HttpClient();
try {
client.executeMethod(post);
//System.out.println("post gerceklesti.");
} catch (Exception e) {
e.printStackTrace();
break;
} finally {
post.releaseConnection();
}
}
}
}
The Exception :
java.net.BindException: Address already in use: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.<init>(Socket.java:309)
at java.net.Socket.<init>(Socket.java:124)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:86)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:652)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:628)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:497)
at alper.StressTest.main(StressTest.java:25)