|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.postgresql.core.PGStream
public class PGStream
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 | |
|---|---|
PGStream(java.lang.String host,
int port)
Constructor: Connect to the PostgreSQL back end and return a stream connection. |
|
| Method Summary | |
|---|---|
void |
changeSocket(java.net.Socket socket)
Switch this stream to using a new socket. |
void |
close()
Closes the connection |
void |
flush()
Flush any pending output to the backend. |
Encoding |
getEncoding()
|
java.io.Writer |
getEncodingWriter()
Get a Writer instance that encodes directly onto the underlying stream. |
java.lang.String |
getHost()
|
int |
getPort()
|
java.net.Socket |
getSocket()
|
boolean |
hasMessagePending()
Check for pending backend messages without blocking. |
void |
Receive(byte[] buf,
int off,
int siz)
Reads in a given number of bytes from the backend |
byte[] |
Receive(int siz)
Reads in a given number of bytes from the backend |
int |
ReceiveChar()
Receives a single character from the backend |
void |
ReceiveEOF()
Consume an expected EOF from the backend |
int |
ReceiveInteger2()
Receives a two byte integer from the backend |
int |
ReceiveInteger4()
Receives a four byte integer from the backend |
java.lang.String |
ReceiveString()
Receives a null-terminated string from the backend. |
java.lang.String |
ReceiveString(int len)
Receives a fixed-size string from the backend. |
byte[][] |
ReceiveTupleV2(int nf,
boolean bin)
Read a tuple from the back end. |
byte[][] |
ReceiveTupleV3()
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 a fixed-size array of bytes to the backend. |
void |
Send(byte[] buf,
int off,
int siz)
Send a fixed-size array of bytes to the backend. |
void |
SendChar(int val)
Sends a single character to the back end |
void |
SendInteger2(int val)
Sends a 2-byte integer (short) to the back end |
void |
SendInteger4(int val)
Sends a 4-byte integer to the back end |
void |
SendStream(java.io.InputStream inStream,
int remaining)
Copy data from an input stream to the connection. |
void |
setEncoding(Encoding encoding)
Change the encoding used by this connection. |
void |
Skip(int size)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PGStream(java.lang.String host,
int port)
throws java.io.IOException
host - the hostname to connect toport - the port number that the postmaster is sitting on
java.io.IOException - if an IOException occurs below it.| Method Detail |
|---|
public java.lang.String getHost()
public int getPort()
public java.net.Socket getSocket()
public boolean hasMessagePending()
throws java.io.IOException
java.io.IOException
public void changeSocket(java.net.Socket socket)
throws java.io.IOException
socket - the new socket to change to
java.io.IOException - if something goes wrongpublic Encoding getEncoding()
public void setEncoding(Encoding encoding)
throws java.io.IOException
encoding - the new encoding to use
java.io.IOException - if something goes wrong
public java.io.Writer getEncodingWriter()
throws java.io.IOException
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 flush() to actually ensure all output
has been pushed to the server.
java.io.IOException - if something goes wrong.
public void SendChar(int val)
throws java.io.IOException
val - the character to be sent
java.io.IOException - if an I/O error occurs
public void SendInteger4(int val)
throws java.io.IOException
val - the integer to be sent
java.io.IOException - if an I/O error occurs
public void SendInteger2(int val)
throws java.io.IOException
val - the integer to be sent
java.io.IOException - if an I/O error occurs or val cannot be encoded in 2 bytes
public void Send(byte[] buf)
throws java.io.IOException
buf - The array of bytes to be sent
java.io.IOException - if an I/O error occurs
public void Send(byte[] buf,
int siz)
throws java.io.IOException
buf - the array of bytes to be sentsiz - the number of bytes to be sent
java.io.IOException - if an I/O error occurs
public void Send(byte[] buf,
int off,
int siz)
throws java.io.IOException
buf - the array of bytes to be sentoff - offset in the array to start sending fromsiz - the number of bytes to be sent
java.io.IOException - if an I/O error occurs
public int ReceiveChar()
throws java.io.IOException
java.io.IOException - if an I/O Error occurs
public int ReceiveInteger4()
throws java.io.IOException
java.io.IOException - if an I/O error occurs
public int ReceiveInteger2()
throws java.io.IOException
java.io.IOException - if an I/O error occurs
public java.lang.String ReceiveString(int len)
throws java.io.IOException
len - the length of the string to receive, in bytes.
java.io.IOException
public java.lang.String ReceiveString()
throws java.io.IOException
java.io.IOException - if an I/O error occurs, or end of file
public byte[][] ReceiveTupleV3()
throws java.io.IOException,
java.lang.OutOfMemoryError
java.io.IOException - if a data I/O error occurs
java.lang.OutOfMemoryError
public byte[][] ReceiveTupleV2(int nf,
boolean bin)
throws java.io.IOException,
java.lang.OutOfMemoryError
nf - the number of fields expectedbin - true if the tuple is a binary tuple
java.io.IOException - if a data I/O error occurs
java.lang.OutOfMemoryError
public byte[] Receive(int siz)
throws java.io.IOException
siz - number of bytes to read
java.io.IOException - if a data I/O error occurs
public void Receive(byte[] buf,
int off,
int siz)
throws java.io.IOException
buf - buffer to store resultoff - offset in buffersiz - number of bytes to read
java.io.IOException - if a data I/O error occurs
public void Skip(int size)
throws java.io.IOException
java.io.IOException
public void SendStream(java.io.InputStream inStream,
int remaining)
throws java.io.IOException
inStream - the stream to read data fromremaining - the number of bytes to copy
java.io.IOException
public void flush()
throws java.io.IOException
java.io.IOException - if an I/O error occurs
public void ReceiveEOF()
throws java.sql.SQLException,
java.io.IOException
java.sql.SQLException - if we get something other than an EOF
java.io.IOException
public void close()
throws java.io.IOException
java.io.IOException - if an I/O Error occurs
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||