public Connection()
{}
+ public void cancelQuery() throws SQLException
+ {
+ PG_Stream cancelStream = null;
+ try {
+ cancelStream = new PG_Stream(PG_HOST, PG_PORT);
+ } catch (ConnectException cex) {
+ // ConnectException is thrown when the connection cannot be made.
+ // we trap this an return a more meaningful message for the end user
+ throw new PSQLException ("postgresql.con.refused");
+ } catch (IOException e) {
+ throw new PSQLException ("postgresql.con.failed",e);
+ }
+
+ // Now we need to construct and send a cancel packet
+ try {
+ cancelStream.SendInteger(16, 4);
+ cancelStream.SendInteger(80877102, 4);
+ cancelStream.SendInteger(pid, 4);
+ cancelStream.SendInteger(ckey, 4);
+ cancelStream.flush();
+ }
+ catch(IOException e) {
+ throw new PSQLException("postgresql.con.failed",e);
+ }
+ finally {
+ try {
+ if(cancelStream != null)
+ cancelStream.close();
+ }
+ catch(IOException e) {} // Ignore
+ }
+ }
+
/*
* This method actually opens the connection. It is called by Driver.
*
switch (beresp)
{
case 'K':
- pid = pg_stream.ReceiveInteger(4);
- ckey = pg_stream.ReceiveInteger(4);
+ pid = pg_stream.ReceiveIntegerR(4);
+ ckey = pg_stream.ReceiveIntegerR(4);
break;
case 'E':
case 'N':
switch (beresp)
{
case 'Z':
+
+ try
+ {
+ pg_stream.SendChar('Q');
+ pg_stream.SendChar(' ');
+ pg_stream.SendChar(0);
+ pg_stream.flush();
+ } catch (IOException e) {
+ throw new PSQLException("postgresql.con.ioerror",e);
+ }
break;
case 'E':
case 'N':
* @return the user name
* @exception SQLException just in case...
*/
+ int lastMessage = 0;
public String getUserName() throws SQLException
{
return PG_USER;