Skip site navigation (1) Skip section navigation (2)

JDBC broken connection against Postgres 8.4

From: Michael Bell <mikebell90(at)yahoo(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: JDBC broken connection against Postgres 8.4
Date: 2009-08-17 07:27:31
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc
As you see below, something seems....whacked. A simple loop with an unpooled connection (code provided below) often gives an exception when connecting. The Thread.sleep statement has been made as high as 5000 ms, and exceptions still sporadically occur.

I don't know if this is a JDBC driver issue or core server issue. Or something here. But the code is so simple....

Single box test (client, server on same machine, accessing
Postgesql 8.4.01
JDBC3 8.4.701 (also tried 8.3.603)
Sun JDK 1.5_16
Windows XP SP3, 2GB RAM, 64MB-1GB heap

Exception in thread "main" org.postgresql.util.PSQLException: The connection attempt failed.
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
    at org.postgresql.core.ConnectionFactory.openConnection(
    at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(
    at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(
    at org.postgresql.jdbc3.Jdbc3Connection.<init>(
    at org.postgresql.Driver.makeConnection(
    at org.postgresql.Driver.connect(
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at com.gwava.db.DerbyConnectionPool.main(
Caused by: Connection reset
    at Source)
    at org.postgresql.core.VisibleBufferedInputStream.readMore(
    at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(
    at org.postgresql.core.PGStream.ReceiveChar(
    at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(
    at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(
    ... 9 more

Code to reproduce:

 public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException, InterruptedException {
        Connection con=null;
        int count=0;
        while (count < 250) {
        try {
            con= DriverManager.getConnection("jdbc:postgresql://localhost/retain","mjb","turnip");
        } finally {
            if (con != null) con.close();



pgsql-jdbc by date

Next:From: Michael BellDate: 2009-08-17 08:00:10
Subject: JDBC Connection broken (followup)
Previous:From: Vikas ZachariaDate: 2009-08-15 08:05:55
Subject: Connection btween Jdeveloper & postgresql 8.3

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group