From: Michael Bell <mikebell90@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: JDBC broken connection against Postgres 8.4
Date: Mon, 17 Aug 2009 00:27:31 -0700 (PDT)
Message-ID: <400613.99933.qm@web43143.mail.sp1.yahoo.com> (raw)
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 127.0.0.1)
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(ConnectionFactoryImpl.java:137)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:124)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:386)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.gwava.db.DerbyConnectionPool.main(DerbyConnectionPool.java:193)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:135)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:104)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:73)
at org.postgresql.core.PGStream.ReceiveChar(PGStream.java:259)
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:254)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:95)
... 9 more
Code to reproduce:
public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException, InterruptedException {
Connection con=null;
Class.forName("org.postgresql.Driver").newInstance();
int count=0;
while (count < 250) {
try {
System.out.println(count);
con= DriverManager.getConnection("jdbc:postgresql://localhost/retain","mjb","turnip");
} finally {
if (con != null) con.close();
}
Thread.sleep(2);
count++;
}
}
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mikebell90@yahoo.com
Subject: Re: JDBC broken connection against Postgres 8.4
In-Reply-To: <400613.99933.qm@web43143.mail.sp1.yahoo.com>
References: <400613.99933.qm@web43143.mail.sp1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox