JDBC broken connection against Postgres 8.4 - Mailing list pgsql-jdbc
From | Michael Bell |
---|---|
Subject | JDBC broken connection against Postgres 8.4 |
Date | |
Msg-id | 400613.99933.qm@web43143.mail.sp1.yahoo.com Whole thread Raw |
Responses |
Re: JDBC broken connection against Postgres 8.4
Re: JDBC broken connection against Postgres 8.4 |
List | pgsql-jdbc |
As you see below, something seems....whacked. A simple loop with an unpooled connection (code provided below) often givesan exception when connecting. The Thread.sleep statement has been made as high as 5000 ms, and exceptions still sporadicallyoccur. 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++; } }
pgsql-jdbc by date: