From: zxcv@infoweb.cz
To: pgsql-jdbc@postgresql.org
Subject: SocketException: Connection reset
Date: Thu, 19 Feb 2009 17:46:06 +0100
Message-ID: <20090219164640.0DBAE5881E0@arachne.itcomputers.cz> (raw)
Hi,
my problem is simple, but frustrating for me:
JDBC driver: postgresql-8.3-604.jdbc4.jar
Server: PostgreSQL 8.3.5, compiled by Visual C++
build 1400
Code (found cause, so very simplified):
public class Main {
public static void main(String[] args) throws
Exception
{
java.util.Properties props = new
java.util.Properties();
props.setProperty(\"user\", \"postgres\");
props.setProperty(\"password\",
\"secretpassword\");
for (int i = 0; i < 100; i++)
{
System.out.println(\"attempt number \"
+ i);
java.sql.Connection con =
java.sql.DriverManager.getConnection(
\"jdbc:postgresql://localhost:5432/my\", propsDB);
con.close();
}
}
}
Code produces (... for abbreviation):
run:
attempt number 0
attempt number 1
...
attempt number 68
attempt number 69
Exception in thread \"main\"
org.postgresql.util.PSQLException: The connection
attempt failed.
at
org.postgresql.Driver$ConnectThread.getResult(Driver.java:341)
at
org.postgresql.Driver.connect(Driver.java:264)
at
java.sql.DriverManager.getConnection(DriverManager.java:582)
at
java.sql.DriverManager.getConnection(DriverManager.java:154)
at sometests.Main.main(Main.java:85)
Caused by: java.net.SocketException: Connection
reset
at
java.net.SocketInputStream.read(SocketInputStream.java:168)
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.v2.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:207)
at
org.postgresql.core.v2.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:76)
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.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:29)
at
org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at
org.postgresql.Driver.makeConnection(Driver.java:386)
at
org.postgresql.Driver.access$100(Driver.java:47)
at
org.postgresql.Driver$ConnectThread.run(Driver.java:301)
at java.lang.Thread.run(Thread.java:619)
Java Result: 1
Sometimes it happens after just 8 attempts,
sometimes after 80, sometimes after 780 attempts.
I googled for some
time, no solution found.
Thank you for any suggestions.
z
--- === www.INFOWEB.cz === ---
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: zxcv@infoweb.cz
Subject: Re: SocketException: Connection reset
In-Reply-To: <20090219164640.0DBAE5881E0@arachne.itcomputers.cz>
References: <20090219164640.0DBAE5881E0@arachne.itcomputers.cz>
* 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