public class PGCopyInputStream extends java.io.InputStream implements CopyOut
| Modifier and Type | Field and Description |
|---|---|
private int |
at |
private byte[] |
buf |
private int |
len |
private CopyOut |
op |
| Constructor and Description |
|---|
PGCopyInputStream(CopyOut op)
Use given CopyOut operation for reading.
|
PGCopyInputStream(PGConnection connection,
java.lang.String sql)
Uses given connection for specified COPY TO STDOUT operation.
|
| Modifier and Type | Method and Description |
|---|---|
int |
available() |
void |
cancelCopy()
Cancels this copy operation, discarding any exchanged data.
|
private void |
checkClosed() |
void |
close() |
int |
getFieldCount() |
int |
getFieldFormat(int field) |
int |
getFormat() |
long |
getHandledRowCount()
After successful end of copy, returns the number of database records handled in that operation.
|
private boolean |
gotBuf() |
boolean |
isActive() |
int |
read() |
int |
read(byte[] buf) |
int |
read(byte[] buf,
int off,
int siz) |
byte[] |
readFromCopy()
Blocks wait for a row of data to be received from server on an active copy operation.
|
byte[] |
readFromCopy(boolean block)
Wait for a row of data to be received from server on an active copy operation.
|
private CopyOut op
private byte[] buf
private int at
private int len
public PGCopyInputStream(PGConnection connection, java.lang.String sql) throws java.sql.SQLException
connection - database connection to use for copying (protocol version 3 required)sql - COPY TO STDOUT statementjava.sql.SQLException - if initializing the operation failspublic PGCopyInputStream(CopyOut op)
op - COPY TO STDOUT operationprivate boolean gotBuf()
throws java.io.IOException
java.io.IOExceptionprivate void checkClosed()
throws java.io.IOException
java.io.IOExceptionpublic int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] buf)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] buf,
int off,
int siz)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic byte[] readFromCopy()
throws java.sql.SQLException
CopyOutreadFromCopy in interface CopyOutjava.sql.SQLException - if something goes wrong for example socket timeoutpublic byte[] readFromCopy(boolean block)
throws java.sql.SQLException
CopyOutreadFromCopy in interface CopyOutblock - true if need wait data from server otherwise false and will read
pending message from serverjava.sql.SQLException - if something goes wrong for example socket timeoutpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic void cancelCopy()
throws java.sql.SQLException
CopyOperationcancelCopy in interface CopyOperationjava.sql.SQLException - if cancelling failspublic int getFormat()
getFormat in interface CopyOperationpublic int getFieldFormat(int field)
getFieldFormat in interface CopyOperationfield - number of field (0..fieldCount()-1)public int getFieldCount()
getFieldCount in interface CopyOperationpublic boolean isActive()
isActive in interface CopyOperationpublic long getHandledRowCount()
CopyOperationgetHandledRowCount in interface CopyOperation