Problem : DB2 ERRORCODE=-4499, SQLSTATE=08001

Problem : DB2 ERRORCODE=-4499, SQLSTATE=08001

This error is generated randomly, based on the number of applications running.  If I start up 25 applications, they run creat.  If I open up 10 applications they run great.  If I try to open anothe application an hour later, this message is generated.

Tue Jun 30 14:36:35 EDT 2009 DRIVERFOUND.
Tue Jun 30 14:36:35 EDT 2009 Connecting to database URL = jdbc:db2://
Tue Jun 30 14:36:35 EDT 2009 Failed to connect, reason : [jcc][t4][2043][11550][4.0.100] Exception
eption: Error opening socket to server / on port 50,000 with message:
Address already in use: connect. ERRORCODE=-4499, SQLSTATE=08001
at edi2.EDIMain.mycarrierAppStart(
at edi2.EDIMain.carrierAppStart(
Job is terminated    :
Exception in thread “main” java.lang.NullPointerException
at Source)
at edi2.JobDetails.fileOutputStream(
at edi2.JobDetails.appendToFile(
at edi2.EDIMain.carrierAppStart(


Solution : DB2 ERRORCODE=-4499, SQLSTATE=08001

This is not a proper way to do. Since your application does not close database connections properliy before terminating. There are connections stay open to your database. So they accumulate and it reaches a point that db2 won’t be accepting any more connections.

The best way to avoid the situation is to close all database connections before terminating the application. so I believe you need to modify your program to properly close all db connections before quitting. This is the only viable solution for the time being.

I am still suspecting that your application connects to database through hibernate. So it seems that your application does not close hibernate connections or attempts to reuse and when it starts it opens new connections regardless of the DB connection state. It might be a good idea to check for DB conenction first and attempt to open new connections it if this operation fails.