Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.postgresql
Class PG_Stream  view PG_Stream download PG_Stream.java

java.lang.Object
  extended byorg.postgresql.PG_Stream

public class PG_Stream
extends java.lang.Object

Version:
1.0 15-APR-1997 This class is used by Connection & PGlobj for communicating with the backend.

Field Summary
private  java.net.Socket connection
           
private  java.io.InputStream pg_input
           
private  java.io.BufferedOutputStream pg_output
           
 
Constructor Summary
PG_Stream(java.lang.String host, int port)
          Constructor: Connect to the PostgreSQL back end and return a stream connection.
 
Method Summary
 void close()
          Closes the connection
 void flush()
          This flushes any pending output to the backend.
 void Receive(byte[] b, int off, int siz)
          Reads in a given number of bytes from the backend
private  byte[] Receive(int siz)
          Reads in a given number of bytes from the backend
 int ReceiveChar()
          Receives a single character from the backend
 int ReceiveInteger(int siz)
          Receives an integer from the backend
 int ReceiveIntegerR(int siz)
          Receives an integer from the backend
 java.lang.String ReceiveString(int maxsiz)
          Receives a null-terminated string from the backend.
 byte[][] ReceiveTuple(int nf, boolean bin)
          Read a tuple from the back end.
 void Send(byte[] buf)
          Send an array of bytes to the backend
 void Send(byte[] buf, int siz)
          Send an exact array of bytes to the backend - if the length has not been reached, send nulls until it has.
 void Send(byte[] buf, int off, int siz)
          Send an exact array of bytes to the backend - if the length has not been reached, send nulls until it has.
 void SendChar(int val)
          Sends a single character to the back end
 void SendInteger(int val, int siz)
          Sends an integer to the back end
 void SendIntegerReverse(int val, int siz)
          Sends an integer to the back end in reverse order.
 void SendPacket(byte[] buf)
          Sends a packet, prefixed with the packet's length
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connection

private java.net.Socket connection

pg_input

private java.io.InputStream pg_input

pg_output

private java.io.BufferedOutputStream pg_output
Constructor Detail

PG_Stream

public PG_Stream(java.lang.String host,
                 int port)
          throws java.io.IOException
Constructor: Connect to the PostgreSQL back end and return a stream connection.

Method Detail

SendChar

public void SendChar(int val)
              throws java.io.IOException
Sends a single character to the back end


SendInteger

public void SendInteger(int val,
                        int siz)
                 throws java.io.IOException
Sends an integer to the back end


SendIntegerReverse

public void SendIntegerReverse(int val,
                               int siz)
                        throws java.io.IOException
Sends an integer to the back end in reverse order. This is required when the backend uses the routines in the src/backend/libpq/pqcomprim.c module. As time goes by, this should become obsolete.


Send

public void Send(byte[] buf)
          throws java.io.IOException
Send an array of bytes to the backend


Send

public void Send(byte[] buf,
                 int siz)
          throws java.io.IOException
Send an exact array of bytes to the backend - if the length has not been reached, send nulls until it has.


Send

public void Send(byte[] buf,
                 int off,
                 int siz)
          throws java.io.IOException
Send an exact array of bytes to the backend - if the length has not been reached, send nulls until it has.


SendPacket

public void SendPacket(byte[] buf)
                throws java.io.IOException
Sends a packet, prefixed with the packet's length


ReceiveChar

public int ReceiveChar()
                throws java.sql.SQLException
Receives a single character from the backend


ReceiveInteger

public int ReceiveInteger(int siz)
                   throws java.sql.SQLException
Receives an integer from the backend


ReceiveIntegerR

public int ReceiveIntegerR(int siz)
                    throws java.sql.SQLException
Receives an integer from the backend


ReceiveString

public java.lang.String ReceiveString(int maxsiz)
                               throws java.sql.SQLException
Receives a null-terminated string from the backend. Maximum of maxsiz bytes - if we don't see a null, then we assume something has gone wrong.


ReceiveTuple

public byte[][] ReceiveTuple(int nf,
                             boolean bin)
                      throws java.sql.SQLException
Read a tuple from the back end. A tuple is a two dimensional array of bytes


Receive

private byte[] Receive(int siz)
                throws java.sql.SQLException
Reads in a given number of bytes from the backend


Receive

public void Receive(byte[] b,
                    int off,
                    int siz)
             throws java.sql.SQLException
Reads in a given number of bytes from the backend


flush

public void flush()
           throws java.sql.SQLException
This flushes any pending output to the backend. It is used primarily by the Fastpath code.


close

public void close()
           throws java.io.IOException
Closes the connection