import java.sql.*; public class PingTest { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5820/jurka","jurka",""); conn.setAutoCommit(false); Statement stmt = conn.createStatement(); try { stmt.execute("SELECT 1/0"); } catch (SQLException sqle) { sqle.printStackTrace(); } System.out.println(((org.postgresql.jdbc2.AbstractJdbc2Connection)conn).ping()); stmt.execute("SELECT 1"); } }