| java.lang.Object org.postgresql.core.PGStream
PGStream | public class PGStream (Code) | | Wrapper around the raw connection to the server that implements some basic
primitives (reading/writing formatted data, doing string encoding, etc).
In general, instances of PGStream are not threadsafe; the caller must ensure
that only one thread at a time is accessing a particular PGStream instance.
|
Constructor Summary | |
public | PGStream(String host, int port) Constructor: Connect to the PostgreSQL back end and return
a stream connection. |
PGStream | public PGStream(String host, int port) throws IOException(Code) | | Constructor: Connect to the PostgreSQL back end and return
a stream connection.
Parameters: host - the hostname to connect to Parameters: port - the port number that the postmaster is sitting on exception: IOException - if an IOException occurs below it. |
Receive | public byte[] Receive(int siz) throws IOException(Code) | | Reads in a given number of bytes from the backend
Parameters: siz - number of bytes to read array of bytes received exception: IOException - if a data I/O error occurs |
Receive | public void Receive(byte[] buf, int off, int siz) throws IOException(Code) | | Reads in a given number of bytes from the backend
Parameters: buf - buffer to store result Parameters: off - offset in buffer Parameters: siz - number of bytes to read exception: IOException - if a data I/O error occurs |
ReceiveChar | public int ReceiveChar() throws IOException(Code) | | Receives a single character from the backend
the character received exception: IOException - if an I/O Error occurs |
ReceiveInteger2 | public int ReceiveInteger2() throws IOException(Code) | | Receives a two byte integer from the backend
the integer received from the backend exception: IOException - if an I/O error occurs |
ReceiveInteger4 | public int ReceiveInteger4() throws IOException(Code) | | Receives a four byte integer from the backend
the integer received from the backend exception: IOException - if an I/O error occurs |
ReceiveString | public String ReceiveString(int len) throws IOException(Code) | | Receives a fixed-size string from the backend.
Parameters: len - the length of the string to receive, in bytes. the decoded string |
ReceiveString | public String ReceiveString() throws IOException(Code) | | Receives a null-terminated string from the backend. If we don't see a
null, then we assume something has gone wrong.
string from back end exception: IOException - if an I/O error occurs, or end of file |
ReceiveTupleV2 | public byte[][] ReceiveTupleV2(int nf, boolean bin) throws IOException, OutOfMemoryError(Code) | | Read a tuple from the back end. A tuple is a two dimensional
array of bytes. This variant reads the V2 protocol's tuple
representation.
Parameters: nf - the number of fields expected Parameters: bin - true if the tuple is a binary tuple null if the current response has no more tuples, otherwisean array of bytearrays exception: IOException - if a data I/O error occurs |
ReceiveTupleV3 | public byte[][] ReceiveTupleV3() throws IOException, OutOfMemoryError(Code) | | Read a tuple from the back end. A tuple is a two dimensional
array of bytes. This variant reads the V3 protocol's tuple
representation.
null if the current response has no more tuples, otherwisean array of bytearrays exception: IOException - if a data I/O error occurs |
Send | public void Send(byte buf) throws IOException(Code) | | Send an array of bytes to the backend
Parameters: buf - The array of bytes to be sent exception: IOException - if an I/O error occurs |
Send | public void Send(byte buf, int siz) throws IOException(Code) | | Send a fixed-size array of bytes to the backend. If buf.length < siz,
pad with zeros. If buf.lengh > siz, truncate the array.
Parameters: buf - the array of bytes to be sent Parameters: siz - the number of bytes to be sent exception: IOException - if an I/O error occurs |
Send | public void Send(byte buf, int off, int siz) throws IOException(Code) | | Send a fixed-size array of bytes to the backend. If length < siz,
pad with zeros. If length > siz, truncate the array.
Parameters: buf - the array of bytes to be sent Parameters: off - offset in the array to start sending from Parameters: siz - the number of bytes to be sent exception: IOException - if an I/O error occurs |
SendChar | public void SendChar(int val) throws IOException(Code) | | Sends a single character to the back end
Parameters: val - the character to be sent exception: IOException - if an I/O error occurs |
SendInteger2 | public void SendInteger2(int val) throws IOException(Code) | | Sends a 2-byte integer (short) to the back end
Parameters: val - the integer to be sent exception: IOException - if an I/O error occurs or val cannot be encoded in 2 bytes |
SendInteger4 | public void SendInteger4(int val) throws IOException(Code) | | Sends a 4-byte integer to the back end
Parameters: val - the integer to be sent exception: IOException - if an I/O error occurs |
SendStream | public void SendStream(InputStream inStream, int remaining) throws IOException(Code) | | Copy data from an input stream to the connection.
Parameters: inStream - the stream to read data from Parameters: remaining - the number of bytes to copy |
changeSocket | public void changeSocket(Socket socket) throws IOException(Code) | | Switch this stream to using a new socket. Any existing socket
is not closed; it's assumed that we are changing to
a new socket that delegates to the original socket (e.g. SSL).
Parameters: socket - the new socket to change to throws: IOException - if something goes wrong |
getEncodingWriter | public Writer getEncodingWriter() throws IOException(Code) | | Get a Writer instance that encodes directly onto the underlying stream.
The returned Writer should not be closed, as it's a shared object.
Writer.flush needs to be called when switching between use of the Writer and
use of the PGStream write methods, but it won't actually flush output
all the way out -- call
PGStream.flush to actually ensure all output
has been pushed to the server.
the shared Writer instance throws: IOException - if something goes wrong. |
getPort | public int getPort()(Code) | | |
hasMessagePending | public boolean hasMessagePending() throws IOException(Code) | | Check for pending backend messages without blocking.
Might return false when there actually are messages
waiting, depending on the characteristics of the
underlying socket. This is used to detect asynchronous
notifies from the backend, when available.
true if there is a pending backend message |
setEncoding | public void setEncoding(Encoding encoding) throws IOException(Code) | | Change the encoding used by this connection.
Parameters: encoding - the new encoding to use throws: IOException - if something goes wrong |
|
|