4 messages in com.mysql.lists.javaRe: Running Out of Ports| From | Sent On | Attachments |
|---|---|---|
| Peter Vertes | 16 Dec 2002 15:11 | |
| Mark Matthews | 16 Dec 2002 15:46 | |
| kjc | 16 Dec 2002 15:47 | |
| Peter Vertes | 17 Dec 2002 06:10 |
| Subject: | Re: Running Out of Ports![]() |
|---|---|
| From: | kjc (kcit...@elp.rr.com) |
| Date: | 12/16/2002 03:47:24 PM |
| List: | com.mysql.lists.java |
In your problem description. You mention messages from a queue. Are you using JMS. If so. Are you closing the JMS connection when each of your message retriever threads die.
Peter Vertes wrote:
Hello List,
I've written an java app that does some database activity but shortly into
program execution (after about 5 minutes) the machine executing the program runs
out of ports. When I do a "netstat -a" I find that all of my ports are in a
TIME_WAIT state.
Here's what is happening a little bit more in-depth. I have a certain number of
threads that grab a message from a queue, log into a database, insert the
message into a table and then die. I'm testing this program out using two
databases; a MySQL database and an MSSQL database. I'm using Connector/J to
access the MySQL DB (http://www.mysql.com/downloads/api-jdbc-stable.html) and
I'm using JTDS to access the MSSQL DB (http://jtds.sourceforge.net/) (both are
pure Java type 4 drivers). The database related code is extremely simple,
something along these lines:
---
Class.forName("com.mysql.jdbc.Driver"); Connection dbConnection = DriverManager.getConnection("..."); [1] Statement SqlStatement = dbConnection.createStatement(); SqlStatement.executeQuery("..."); [2] dbConnection.close();
---
As you can see there is nothing fancy going on. At first I didn't have the
"dbConnection.close()" statement but after looking in the documents I figured it
shouldn't hurt to have it in there, and who knows it might solve my problems but
it didn't. Each time a thread dies it leave the port in a TIME_WAIT state and
it takes a good minute of two for it to become available again despite the fact
that I have the "dbConnection.close()" statement in my code. What am I doing
wrong ? Why isn't the close() statement working ? Is it my fault or is this
the "fault" of the JDBC drivers for leaving the ports in an open state ? Any
help would be appreciated. Thanks in advance...
-Pete
P.S.: All this is happening under Windows XP Professional with SP1 installed.
[1] - I've omitted the jdbc URL because it's just too long to put it in there
without having it to wrap in the e-mail
[2] - Same thing as in [1] :)
Peter Vertes Beast Financial Systems 404 Fifth Avenue New York, NY 10018
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/doc/ (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <java...@lists.mysql.com> To unsubscribe, e-mail <java-unsubscribe-kcitron=elp....@lists.mysql.com>




