*** Connection.java.orig Tue Dec 11 04:44:23 2001 --- Connection.java Sun Feb 17 13:01:43 2002 *************** *** 266,273 **** switch (beresp) { case 'K': ! pid = pg_stream.ReceiveInteger(4); ! ckey = pg_stream.ReceiveInteger(4); break; case 'E': case 'N': --- 266,273 ---- switch (beresp) { case 'K': ! pid = pg_stream.ReceiveIntegerR(4); ! ckey = pg_stream.ReceiveIntegerR(4); break; case 'E': case 'N': *************** *** 330,335 **** --- 330,369 ---- firstWarning = null; PG_STATUS = CONNECTION_OK; } + + /** + * This method sends a CancelRequest message to the postmaster + * to request cancellation of the current query. + * + * @exception SQLException if a database access error occurs + */ + public void cancelQuery() throws SQLException { + final int CANCEL_HIGH = 1234; + final int CANCEL_LOW = 5678; + + PG_Stream cancelStream; + + try { + cancelStream = new PG_Stream(PG_HOST, PG_PORT); + } catch (ConnectException ex) { + throw new PSQLException ("postgresql.con.refused"); + } catch (IOException ex) { + throw new PSQLException ("postgresql.con.failed", ex); + } + + try { + cancelStream.SendInteger(16, 4); + cancelStream.SendInteger(CANCEL_HIGH, 2); + cancelStream.SendInteger(CANCEL_LOW, 2); + cancelStream.SendInteger(pid, 4); + cancelStream.SendInteger(ckey, 4); + cancelStream.flush(); + cancelStream.close(); + cancelStream = null; + } catch (IOException ex) { + throw new PSQLException ("postgresql.con.failed", ex); + } + } // These methods used to be in the main Connection implementation. As they // are common to all implementations (JDBC1 or 2), they are placed here. *** Statement.java.orig Sun Nov 25 23:26:56 2001 --- Statement.java Sun Feb 17 12:50:43 2002 *************** *** 172,185 **** /* * Cancel can be used by one thread to cancel a statement that * is being executed by another thread. - *

- * Not implemented, this method is a no-op. * ! * @exception SQLException only because thats the spec. */ public void cancel() throws SQLException { ! // FIXME: Cancel feature has been available since 6.4. Implement it here! } /* --- 172,183 ---- /* * Cancel can be used by one thread to cancel a statement that * is being executed by another thread. * ! * @exception SQLException if a database access error occurs */ public void cancel() throws SQLException { ! connection.cancelQuery(); } /*