Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Does Connection.close() really closing connection?

807569Aug 4 2006 — edited Aug 5 2006
in my previous problem, i'm running out of port because i always create a new connection when i need it. i check all of my

code & i'm sure i'm not forget to call con.close(); every times i don't need that connection anymore. so i wrote my test case

like this:
public static void main(String[] args) throws Exception {
	Class.forName(xxx); //... load driver
	Connection con = DriverManager.getConnection(xxx,xxx,xxx);
	con.close();
}
i run netstat to check port before, while(using Thread.sleep(xxx)) & after running this test case. this is result

after that:
TCP    TOSHIBA2450:3306       localhost:4002         TIME_WAIT
i think calling Connection.close(); only apply to close tcp/ip connection from client side. it will cause server wait until

timeout reached for close connection at server side. am i right? so how to close server side port instantly through our

code?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 2 2006
Added on Aug 4 2006
3 comments
426 views