Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact errors

Posted by redstar (redstar), 11 January 2005

I am developing a java/MySql client server application
I am well advanced with it but have come to a stop caused by the error message below.

The class being run holds fairly simple embedded sql commands that return a value. There may be several hundred calls to the various methods. The method seems to arise in no particular place in the program.
Any suggestion where to start looking would be a great help. I tried closing all the connections once used

a typical method is as follows
public int getShiftDownTime(String date1,String date2,String Shift){

int ShiftDownTime=0;
SetConnectionDT setConShiftDown = new SetConnectionDT();

Connection tcShiftDown=setConShiftDown.getConnectionDT();

Statement stmtShiftDown= tcShiftDown .createStatement();

ResultSet rsShiftDown=null;

String sql8="Select sum(DTElapsedMins),DTDate from downtimelinedata where DTDate between "+ "'" + date1 + "' and "+"'"+date2+"'"+" and STNum ="+"'"+Shift+"'"+" group by DTDate";


catch (SQLException sqe){
return ShiftDownTime;
return 0;


//error message

connection problemjava.sql.SQLException: Unable to connect to any hosts due to exception: Address in use: no further information

Exception occurred during event dispatching:

     at coriolis1_1b.Ops_Rep_Top.getShiftRunTime(

     at coriolis1_1b.Ops_Rep_Top.loadTable(

     at coriolis1_1b.Ops_Rep_Top.<init>(

     at coriolis1_1

Posted by admin (Graham Ellis), 11 January 2005
Hello - been looking to see what I can see here.  I understand that the problem is intermittent - in other words that it occurs at different times / points even if you run the same query a number of times?

The method that you've provided as an example is getShiftDownTime, but the error message example is getShiftRunTime.  I do understand that they're probably very similar, but if you could post the source of the method that exceptioned, it might be useful.  Could you also tell us which is line 5772.

As an educated guess, there's some sort of timing issue here. As a first step to debugging, I would catch the exception and look at the exception object.  As a second step, I would look at using a single thread model - perhaps not as a permanent fix, but to help with the analysis.

Posted by redstar (redstar), 12 January 2005
Hi Graham
Thanks for your comments. Since our last exchange I have reduced the size of my program so that it is only generating a few rows on the jTable. I have got to a point where I can run the the same report 5 times in succession with the same date parameter and on the fifth (or so) attempt it will crash. The row numbers referred to in every crash point to a line of code where a 'Statement 'is created  Also once it has crashed I need to recompile before the program will run again(sometimes even reboot)

example line where crash is identified
Statement stmtAveCo = tcAveCo .createStatement();

I have maybe 20 methods to create the report/jtable and some of these methods may be called 8 times for different date ranges. Is it acceptable to define a single 3 part connection statement at the beginning of my report and to keep reusing it for each method call so that I am using only one connection. All I would then do is vary the resultset name, and I could possibly again keep reusing the same name?

the error message for this statement was

connection problemjava.sql.SQLException: Unable to connect to any hosts due to exception: Address in use: no further information

Exception occurred during event dispatching:
java.lang.NullPointerException      at coriolis1_1b.Ops_Rep_Top.getAveChangeoverTime( at coriolis1_1b.Ops_Rep_Top.loadTable at coriolis1_1b.Ops_Rep_Top.<init>(
at coriolis1_1b.CorMFrame.jMenuItem35_actionPerformed(
the whole method and its calling statement is
//calling the method from

//storing the result in an array-jtable
data [rowCount][8]=df2.format(aveChange);

public int getAveChangeoverTime (String date1,String date2){
String sql="";
int aveSet=0;
int totTime=0;
int totNumSets=0;

SetConnectionDT setConAveCo = new SetConnectionDT();//dates
Connection tcAveCo = setConAveCo.getConnectionDT();
Statement stmtAveCo = tcAveCo .createStatement();

String code="Product Changeover";
//note that the next statement is not as coded but is a copy of the sql line created by the program

String sql="select DTDate,sum(DTElapsedMins),count(*) from downtimelinedata where DTCodeNum= 'Product Changeover' and DTDate between '2004-09-26' and '2004-08-30'  group by DTDate";

ResultSet rsAveCo=stmtAveCo.executeQuery(sql);
catch (SQLException sqe){
return aveSet;


Hope you can help me on this Graham as its driving me mad.

ps thanks for returning my pad.

Best Regards

Posted by admin (Graham Ellis), 13 January 2005
Oh help!  This needs a bit longer to look at than I have at this brief visit to "Opentalk"; I'll come back with a fuller look later.

I did notice:

Also once it has crashed I need to recompile before the program will run again(sometimes even reboot)

And that tells me that it's something to do with caching connections not being released (or similar);  once you recompile, your application server is forced to reload the application as it thinks the code has changed and thus releases the resource that's causing the issue  

What are you hosting on?  Linux or Unix box?? Just as a matter of interest, touch the .class file when you get a problem and see if this re-timestamping lets you run another 5 queries  

Posted by redstar (redstar), 13 January 2005
Hi Graham

I bit more information

I copied the database and software onto my laptop and it ran without a fault?

The database is on a Windows server

Sorry to lumber you with such a weighty problem first time around, but I can't seem to get over it.


Posted by redstar (redstar), 13 January 2005
Hi Graham

I'm making a bit of progress. I found a website that suggested the following

This is a problem of the used sockets with Windows NT. You can request the active sockets with the command netstat. The problem is a function of:

MaxUserPort (default 5000)
KeepAliveTime (default 120)
it suggested the workaround was connection pooling

I have run netstat to look at the number of connections when the problem occurs and waited for the timeout to reset the os back to the minimum and on each occasion my report has run

Does this sound logical?
If so

do you have any examples on connection pooling

Best Regards

Posted by Custard (Custard), 13 January 2005

Not sure how much help this will be, but on this very site, there is a post by myself relating to another question, but the example is of connection pools.;action=display;num=1068719223



This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: • WEB: • SKYPE: wellho