Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 709779FBA08 for ; Tue, 1 May 2007 18:53:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 34196-07 for ; Tue, 1 May 2007 18:53:11 -0300 (ADT) X-Greylist: delayed 00:26:19.06105 by SQLgrey-1.7.4 Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 6E8F39FBA5A for ; Tue, 1 May 2007 18:53:14 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.3 Received: from mailout17.yourhostingaccount.com (mailout17.yourhostingaccount.com [65.254.253.137]) by svr4.postgresql.org (Postfix) with ESMTP id E3ABF5AF024 for ; Tue, 1 May 2007 21:26:53 +0000 (GMT) Received: from mailscan12.yourhostingaccount.com ([10.1.15.12] helo=mailscan12.yourhostingaccount.com) by mailout17.yourhostingaccount.com with esmtp (Exim) id 1Hizs4-0006FG-D2 for pgsql-admin@postgresql.org; Tue, 01 May 2007 17:26:52 -0400 Received: from authsmtp01.yourhostingaccount.com ([10.1.1.155] ident=exim) by mailscan12.yourhostingaccount.com with spamscanlookuphost (Exim) id 1Hizs4-00021d-ES for pgsql-admin@postgresql.org; Tue, 01 May 2007 17:26:52 -0400 Received: from authsmtp01.yourhostingaccount.com ([10.1.1.155] helo=authsmtp01.yourhostingaccount.com) by mailscan12.yourhostingaccount.com with esmtp (Exim) id 1Hizs3-00021a-JA for pgsql-admin@postgresql.org; Tue, 01 May 2007 17:26:51 -0400 Received: from static-70-20-198-26.phil.east.verizon.net ([70.20.198.26] helo=srinilaptop) by authsmtp01.yourhostingaccount.com with esmtpa (Exim) id 1Hizs2-0005Nl-21 for pgsql-admin@postgresql.org; Tue, 01 May 2007 17:26:51 -0400 Reply-To: From: "'Srinivas Kotapally'" To: Subject: Intermittent Postgres Connection refused Errors (JDBC) Date: Tue, 1 May 2007 17:26:47 -0400 Organization: Coriendo LLC Message-ID: <01a101c78c37$6da02450$800101df@srinilaptop> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01A2_01C78C15.E68E8450" X-Mailer: Microsoft Office Outlook 11 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028 Thread-Index: AceMN2xMiQIgFk9PQQiPmjzgZlG+Hg== X-EN-UserInfo: 7b39549d18acd124e97783bb813c9bcc:e25d2d23f680f6c51a71cc9f7fe7a271 X-EN-AuthUser: ksrinivas X-EN-OrigIP: 70.20.198.26 X-EN-OrigHost: static-70-20-198-26.phil.east.verizon.net X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.136 tagged_above=0 required=5 tests=BAYES_50=0.001, HTML_50_60=0.134, HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200705/4 X-Sequence-Number: 25324 This is a multi-part message in MIME format. ------=_NextPart_000_01A2_01C78C15.E68E8450 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Hi I am managing an application that uses the Postgres backend. Of late we have started getting connection refused errors every now and then. We have not been able to identify the cause of this. Any hints or known bugs that I should be aware of? Thanks for any help extended! Regards Srinivas Here is the environment I work in: Application is a Java app residing on a web server and is running on Tomcat. Versions: jdk: 1.5.0_02 Tomcat 5.5.23 Web server: httpd-2.0.52-28.ent.centos4 Kernel: Linux version 2.6.9-42.0.10.ELsmp (mockbuild@builder5.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)) #1 SMP Tue Feb 27 09:40:21 EST 2007 Postgres: 8.1.8 (64 bit version) - postgresql-libs-8.1.8-1PGDG postgresql-8.1.8-1PGDG postgresql-server-8.1.8-1PGDG postgresql-contrib-8.1.8-1PGDG We use the JDBC2 driver that comes with Postgres. The specific error we get is: CDBConnectionPool.newConnection() : SQLException= org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. Our CDBConnectionPool class as below (this is a class that we have implemented to establish BD connections): import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; class CDBConnectionPool { public synchronized Connection getConnection(String stIPAddress,String stPort,String stDataBaseName, String stUser,String stPassword,String stDBType) { Connection con = null; try { con = newConnection(stIPAddress,stPort,stDataBaseName,stDBType,stUser,stPassword); } catch(Exception e) { Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.getConnection:Except ion="+e); } return con; } private Connection newConnection(String stIPAddress,String stPort,String stDataBaseName,String stDBType,String stUser,String stPassword) { Connection con = null; try { String stURL = ""; String stClassName = ""; if (stDBType.equals("ORACLE")) { stURL = "jdbc:oracle:thin:@"+ stIPAddress + ":" + stPort + ":" + stDataBaseName ; stClassName = "oracle.jdbc.driver.OracleDriver"; } else if(stDBType.equals("POSTGRES")) { stURL = "jdbc:postgresql://"+stIPAddress+":"+stPort+"/"+stDataBaseName; stClassName = "org.postgresql.Driver"; } else if(stDBType.equals("MS-SQL2000")) { stURL = "jdbc:microsoft:sqlserver://"+stIPAddress+":"+stPort+";DatabaseName="+stDataBase Name; stClassName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"; } else if(stDBType.equals("SYBASE")) { stURL = "jdbc:sybase:Tds:"+stIPAddress+":"+stPort+"/"+stDataBaseName; stClassName = "com.sybase.jdbc2.jdbc.SybDriver"; } else if(stDBType.equals("DB2")) { stURL = "jdbc:db2://"+stIPAddress+":"+stPort+"/"+stDataBaseName; stClassName = "COM.ibm.db2.jdbc.net.DB2Driver"; } Class.forName(stClassName); con = DriverManager.getConnection(stURL,stUser,stPassword); } catch(SQLException sqle) { if(sqle.toString().indexOf("too many clients")>=0) { Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.newConnection() : Maxmimum connections Reached. Waiting for connections to freeup."); con = newConnection(stIPAddress,stPort,stDataBaseName,stDBType,stUser,stPassword); } else { Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.newConnection() : SQLException= " + sqle); } } catch(ClassNotFoundException e) { Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.newConnection() : ClassNotFoundException = " + e.getCause()); } catch(Exception e) { Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.newConnection() : Exception= " + e); } return con; } public void freeConnection(Connection con,String stDataBaseName) { try { con.close(); }catch(Exception e){Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.freeConnection : Exception= " + e);} } } ------=_NextPart_000_01A2_01C78C15.E68E8450 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable
Hi
 
I am = managing an=20 application that uses the Postgres backend.  Of late we have = started=20 getting connection refused errors every now and then.  We have not = been=20 able to identify the cause of this.  Any hints or known bugs that I = should=20 be aware of?  Thanks for any help extended!
 
Regards

Srinivas
 
Here = is the=20 environment I work in:
Application is a Java app residing on a web = server and=20 is running on Tomcat. 
Versions:
jdk:=20 1.5.0_02
Tomcat = 5.5.23
Web = server:=20 httpd-2.0.52-28.ent.centos4
Kernel: Linux=20 version 2.6.9-42.0.10.ELsmp (mockbuild@builder5.centos.o= rg)=20 (gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)) #1 SMP Tue Feb 27 = 09:40:21 EST=20 2007
Postgres: 8.1.8 (64 bit version) -
postgresql-libs-8.1.8-1PGDG
postgresql-8.1.8-1PGDG
postgre= sql-server-8.1.8-1PGDG
postgresql-contrib-8.1.8-1PGDG
 
We use = the JDBC2=20 driver that comes with Postgres.
 
The = specific error=20 we get is:
 
CDBConnectionPool.newConnection() : SQLException=3D=20 org.postgresql.util.PSQLException: Connection refused. Check that the = hostname=20 and port are correct and that the postmaster is accepting TCP/IP=20 connections.
 
Our=20 CDBConnectionPool class as below (this is a class that we have = implemented to=20 establish BD connections):
 
import = java.sql.Connection;
import java.sql.DriverManager;
import=20 java.sql.SQLException;
import java.util.Enumeration;
import=20 java.util.Hashtable;
import java.util.Vector;
 
class=20 CDBConnectionPool
{
 public synchronized Connection=20 getConnection(String stIPAddress,String stPort,String stDataBaseName, = String=20 stUser,String stPassword,String = stDBType)
 {
  Connection=20 con =3D = null;
  try
  {
   con =3D=20 newConnection(stIPAddress,stPort,stDataBaseName,stDBType,stUser,stPasswor= d);
  }
  catch(Exception=20 e)
  {
   Logger.toLog("CONNECTION",stData= BaseName,"CDBConnectionPool.getConnection:Exception=3D"+e);
 &nbs= p;}
  return=20 con;
 }
 
 private=20 Connection newConnection(String stIPAddress,String stPort,String=20 stDataBaseName,String stDBType,String stUser,String=20 stPassword)
 {
  Connection con =3D=20 null;
  try
  {
   String = stURL =3D=20 "";
   String stClassName =3D "";
 
   if=20 (stDBType.equals("ORACLE"))
   {
   &= nbsp;stURL=20 =3D "jdbc:oracle:thin:@"+ stIPAddress + ":" + stPort + ":" + = stDataBaseName=20 ;
    stClassName =3D=20 "oracle.jdbc.driver.OracleDriver";
   }
  =  else=20 if(stDBType.equals("POSTGRES"))
   {
  &nb= sp; stURL=20 =3D=20 "jdbc:postgresql://"+stIPAddress+":"+stPort+"/"+stDataBaseName;
 =    stClassName=20 =3D=20  "org.postgresql.Driver";
   }
  &nbs= p;else=20 if(stDBType.equals("MS-SQL2000"))
   {
  &= nbsp; stURL=20 =3D=20 "jdbc:microsoft:sqlserver://"+stIPAddress+":"+stPort+";DatabaseName=3D"+s= tDataBaseName;
    stClassName=20 =3D=20 "com.microsoft.jdbc.sqlserver.SQLServerDriver";
   }   else=20 if(stDBType.equals("SYBASE"))
   {
   = ; stURL=20 =3D=20 "jdbc:sybase:Tds:"+stIPAddress+":"+stPort+"/"+stDataBaseName;
 &n= bsp;  stClassName=20 =3D=20 "com.sybase.jdbc2.jdbc.SybDriver";
   }
  =  else=20 if(stDBType.equals("DB2"))
   {
   &n= bsp;=20 stURL =3D=20 "jdbc:db2://"+stIPAddress+":"+stPort+"/"+stDataBaseName;
  &= nbsp; =20 stClassName =3D=20 "COM.ibm.db2.jdbc.net.DB2Driver";
   }
 
   Class.forName(stClassName);
 
   con =3D=20 DriverManager.getConnection(stURL,stUser,stPassword);
  &nbs= p;  =20  }
       catch(SQLException=20 sqle)
     =20  {
   if(sqle.toString().indexOf("too many=20 clients")>=3D0)
   {
    Logg= er.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.newConnection()=20 : Maxmimum connections Reached. Waiting for connections to=20 freeup.");
    con =3D=20 newConnection(stIPAddress,stPort,stDataBaseName,stDBType,stUser,stPasswor= d);
   }
   else
   = ;{
    Logger.toLog("CONNECTION",stDataBaseName,"C= DBConnectionPool.newConnection()=20 : SQLException=3D " +=20 sqle);
   }
  }
  catch(Class= NotFoundException=20 e)
  {
   Logger.toLog("CONNECTION",stData= BaseName,"CDBConnectionPool.newConnection()=20 : ClassNotFoundException =3D " +=20 e.getCause());
  }
     =20  catch(Exception e)
     =20  {
   Logger.toLog("CONNECTION",stDataBaseName,"CD= BConnectionPool.newConnection()=20 : Exception=3D " + e);
  }
  return=20 con;
 }
 
 public void=20 freeConnection(Connection con,String=20 stDataBaseName)
 {
  try
  {
 &= nbsp; con.close();
 
  }catch(Exception=20 e){Logger.toLog("CONNECTION",stDataBaseName,"CDBConnectionPool.freeConnec= tion :=20 Exception=3D " + = e);}
 }
}
------=_NextPart_000_01A2_01C78C15.E68E8450--