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://10.20.1.125
:50000/EdiMain
a1.1com.ibm.db2.jcc.DB2Driver@5ac072
Tue Jun 30 14:36:35 EDT 2009 Failed to connect, reason :
com.ibm.db2.jcc.a.pm: [jcc][t4][2043][11550][4.0.100] Exception java.net.BindExc
eption: Error opening socket to server /10.20.1.125 on port 50,000 with message:
Address already in use: connect. ERRORCODE=-4499, SQLSTATE=08001
java.lang.NullPointerException
at edi2.EDIMain.mycarrierAppStart(EDIMain.java:472)
at edi2.EDIMain.carrierAppStart(EDIMain.java:293)
at ANTHEMBCBSMO.ANTHEMBCBSMOMain.main(ANTHEMBCBSMOMain.java:38)
Exceptionnull
Job is terminated    :
Exception in thread “main” java.lang.NullPointerException
at java.io.DataOutputStream.writeBytes(Unknown Source)
at edi2.JobDetails.fileOutputStream(JobDetails.java:99)
at edi2.JobDetails.appendToFile(JobDetails.java:91)
at edi2.EDIMain.carrierAppStart(EDIMain.java:328)
at ANTHEMBCBSMO.ANTHEMBCBSMOMain.main(ANTHEMBCBSMOMain.java:38)


 

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.