jxDBCon 0.9z

org.sourceforge.jxdbcon.postgresql
Class NetProtocolV2

java.lang.Object
  |
  +--org.sourceforge.jxdbcon.postgresql.NetProtocol
        |
        +--org.sourceforge.jxdbcon.postgresql.NetProtocolV1
              |
              +--org.sourceforge.jxdbcon.postgresql.NetProtocolV2
All Implemented Interfaces:
InfoKeys, PGConstants, PGInfoKeys, PGProtocol
Direct Known Subclasses:
NetProtocolV2Async, NetProtocolV2SSL

public class NetProtocolV2
extends NetProtocolV1

The NetProtocolV2 is the protocol implementation for V2. The V2 protocol is used by PostgreSQL 6.4.2, and up. All message types supported by the current (v2) version of the protocol are handled.

Version:
$Revision: 1.13 $
Author:
Keve Müller

Nested Class Summary
(package private)  class NetProtocolV2.BackendKeyData
          Fetch the backend key data.
(package private) static class NetProtocolV2.ReadyForQuery
          Fetch the ready-for-query response.
 
Nested classes inherited from class org.sourceforge.jxdbcon.postgresql.NetProtocolV1
NetProtocolV1.AsciiRow, NetProtocolV1.Authentication, NetProtocolV1.BinaryRow, NetProtocolV1.CompletedResponse, NetProtocolV1.CursorResponse, NetProtocolV1.EmptyQueryResponse, NetProtocolV1.ErrorResponse, NetProtocolV1.FunctionResult, NetProtocolV1.MessageResponse, NetProtocolV1.NoticeResponse, NetProtocolV1.NotificationResponse, NetProtocolV1.RowDescription
 
Field Summary
private  int backendPID
          The backend PID for cancel requests.
private  int cancelSecret
          The cancel secret.
 
Fields inherited from class org.sourceforge.jxdbcon.postgresql.NetProtocolV1
nFields
 
Fields inherited from class org.sourceforge.jxdbcon.postgresql.NetProtocol
copyInStream, copyOutStream, in, lock, messageEncoding, out, socket
 
Fields inherited from interface org.sourceforge.jxdbcon.postgresql.PGConstants
AUTH_REQ_CRYPT, AUTH_REQ_KRB4, AUTH_REQ_KRB5, AUTH_REQ_MD5, AUTH_REQ_OK, AUTH_REQ_PASSWORD, AUTH_REQ_SCM, NUMERIC_DSCALE_MASK, NUMERIC_NAN, NUMERIC_NEG, NUMERIC_POS, NUMERIC_SIGN_MASK, PG_VERSION_STR, PG_VERSION_STR1, TRIGGER_TYPE_BEFORE, TRIGGER_TYPE_DELETE, TRIGGER_TYPE_INSERT, TRIGGER_TYPE_ROW, TRIGGER_TYPE_UPDATE
 
Fields inherited from interface org.sourceforge.jxdbcon.postgresql.PGInfoKeys
FORCECLIENTENC, OPTIONS, PROTOVERSION, SETTIMEZONE, STRICTSCHEMA, TTY, USEASYNC, USECLIENTENC, USEDBENC, USESSL
 
Fields inherited from interface org.sourceforge.jxdbcon.InfoKeys
CATALOG, DESCRIPTION, DRIVER, HOST, PASSWORD, PORT, SUBDRIVER, USER
 
Constructor Summary
NetProtocolV2()
           
 
Method Summary
 void close()
          Close the connection to the backend.
 void connect(Properties info)
          Open the connection.
protected  NetProtocolV1.Response dispatch(int ch)
          Identify the message by the transmitted first character.
protected  void doLogin(Properties info)
           
 PGFuncResult exec(long funcOid, byte[][] param)
          Execute a function.
 PGExecResult exec(String sql)
          Execute a command.
 void requestCancel()
          Request cancellation of current query processing.
protected  void sendStartup(String catalog, String user, String pgoptions, String pgtty)
          Send the V2 startup packet.
 
Methods inherited from class org.sourceforge.jxdbcon.postgresql.NetProtocolV1
readFirst, sendClose, sendFunctionCall, sendPassword, sendQuery, sendStartup
 
Methods inherited from class org.sourceforge.jxdbcon.postgresql.NetProtocol
connectSocket, limString, readCString, setCopyInStream, setCopyOutStream, setMessageEncoding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backendPID

private int backendPID
The backend PID for cancel requests.


cancelSecret

private int cancelSecret
The cancel secret.

Constructor Detail

NetProtocolV2

public NetProtocolV2()
Method Detail

close

public void close()
           throws SQLException
Description copied from interface: PGProtocol
Close the connection to the backend.

SQLException

connect

public void connect(Properties info)
             throws SQLException
Open the connection. The following properties are recognized:
InfoKeys.HOST (defaults to localhost), InfoKeys.PORT (defaults to 5432) InfoKeys.CATALOG (The database name, defaults to template1) InfoKeys.USER, InfoKeys.PASSWORD (defaults to "") PGInfoKeys.OPTIONS, PGInfoKeys.TTY, PGInfoKeys.USESSL, PGInfoKeys.USEASYNC

SQLException
See Also:
InfoKeys, PGInfoKeys

dispatch

protected NetProtocolV1.Response dispatch(int ch)
                                   throws IOException
Description copied from class: NetProtocolV1
Identify the message by the transmitted first character. This routine also performs COPY functions.

Overrides:
dispatch in class NetProtocolV1
Returns:
null if the character code does not map to a valid message, else the message instance
IOException

doLogin

protected void doLogin(Properties info)
                throws SQLException
SQLException

exec

public PGFuncResult exec(long funcOid,
                         byte[][] param)
Description copied from interface: PGProtocol
Execute a function.


exec

public PGExecResult exec(String sql)
Execute a command. The command string is converted into a byte array using the connection's messageEncoding.


requestCancel

public void requestCancel()
                   throws SQLException
Request cancellation of current query processing. Opens a new socket to the backend and emits the cancel request.

SQLException

sendStartup

protected void sendStartup(String catalog,
                           String user,
                           String pgoptions,
                           String pgtty)
                    throws IOException
Send the V2 startup packet.

Overrides:
sendStartup in class NetProtocolV1
IOException

jxDBCon 0.9z

Copyright © 2001,2002 Keve Müller; see LICENSE file for details.