import java.sql.*;

public class Test {
   static final String DB_URL = "jdbc:postgresql://localhost/postgres?user=postgres&prepareThreshold=1";

   public static void main(String[] args) {
      Connection conn = null;
      // Open a connection
      try {
	conn = DriverManager.getConnection(DB_URL);
	conn.setAutoCommit(true);
	PreparedStatement statement2 = conn.prepareStatement("select pg_sleep(10)");
	statement2.execute();
	PreparedStatement statement = conn.prepareStatement("select from foo where id = ?");
	statement.setInt(1, 1);
	statement.execute();
	statement.execute();
	statement.execute();
	statement.execute();
	statement.close();
      } catch (SQLException e) {
         e.printStackTrace();
	 try {
	 	conn.rollback();
	} catch (SQLException ee) {
		ee.printStackTrace();
	}
      }
   }
}
