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

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 (view raw or flat)
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

pgsql-jdbc by date

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

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