After server restart I get - An I/O error occured while sending to the backend.

From: Rod <cckramer(at)gmail(dot)com>
To: pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: After server restart I get - An I/O error occured while sending to the backend.
Date: 2010-05-18 10:41:05
Message-ID: AANLkTilHOdiZ0kiIkPg51KGnz9BTgKK4PWQ-3QwzKkrq@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

I have simple JDBC client app running on Jetty.
Using 8.3 JDBC3 driver and PostgreSQL8.3 server running on localhost.

Any time I restart the PostgresQL server I get SQL error:
An I/O error occured while sending to the backend.

It appears that my application's connection to the server is not
re-established by some reason?

I am no expert in JDBC.
First I was using plan JDBC. I thought that using DB connection pool
will automagically reconnect and solve this problem.
Switching to Apache commons DBCP did not change anything.

What am I supposed to do to make it survive PostgreSQL server restart?

Here is my DB connection manager class:

public class DatabaseProvider {
private static Connection connection;

public void init() throws SQLException {

connection = createConnection();
}

private static Connection createConnection() throws SQLException{
try {
Class.forName(ConfigurationServlet.getConfigurationProperty("database.driver"));
} catch (ClassNotFoundException e) {
System.err.println("Database Driver class not found: " + e.getMessage());
throw new SQLException("Driver class not found: "+e.getMessage());
}

DataSource dataSource =
setupDataSource(ConfigurationServlet.getConfigurationProperty("database.url"));
Connection conn = dataSource.getConnection();
//Connection conn = DriverManager.getConnection(url,dbprops );
return conn;
}

public static DataSource setupDataSource(String connectURI) {
BasicDataSource ds = new BasicDataSource();
ds.setDriverClassName(ConfigurationServlet.getConfigurationProperty("database.driver"));

ds.setUrl(connectURI);
return ds;
}

public void shutdown() {
try {
connection.close();
} catch (SQLException e) {
System.err.println("Error closing connection: "+e.getMessage());
}
}

public static Connection getConnection() {
return connection;
}
}

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Craig Ringer 2010-05-18 11:42:09 Re: After server restart I get - An I/O error occured while sending to the backend.
Previous Message Thomas Kellerer 2010-05-18 09:29:37 JDBC Driver and timezones