public class PGCopyOutputStream extends OutputStream implements CopyIn
| Constructor and Description |
|---|
PGCopyOutputStream(CopyIn op)
Use given CopyIn operation for writing.
|
PGCopyOutputStream(CopyIn op,
int bufferSize)
Use given CopyIn operation for writing.
|
PGCopyOutputStream(PGConnection connection,
String sql)
Uses given connection for specified COPY FROM STDIN operation.
|
PGCopyOutputStream(PGConnection connection,
String sql,
int bufferSize)
Uses given connection for specified COPY FROM STDIN operation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelCopy()
Cancels this copy operation, discarding any exchanged data.
|
void |
close() |
long |
endCopy()
Finishes copy operation successfully.
|
void |
flush() |
void |
flushCopy()
Force any buffered output to be sent over the network to the backend.
|
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.
|
boolean |
isActive() |
void |
write(byte[] buf) |
void |
write(byte[] buf,
int off,
int siz) |
void |
write(int b) |
void |
writeToCopy(byte[] buf,
int off,
int siz)
Writes specified part of given byte array to an open and writable copy operation.
|
void |
writeToCopy(ByteStreamWriter from)
Writes a ByteStreamWriter to an open and writable copy operation.
|
public PGCopyOutputStream(PGConnection connection, String sql) throws SQLException
connection - database connection to use for copying (protocol version 3 required)sql - COPY FROM STDIN statementSQLException - if initializing the operation failspublic PGCopyOutputStream(PGConnection connection, String sql, int bufferSize) throws SQLException
connection - database connection to use for copying (protocol version 3 required)sql - COPY FROM STDIN statementbufferSize - try to send this many bytes at a timeSQLException - if initializing the operation failspublic PGCopyOutputStream(CopyIn op)
op - COPY FROM STDIN operationpublic PGCopyOutputStream(CopyIn op, int bufferSize)
op - COPY FROM STDIN operationbufferSize - try to send this many bytes at a timepublic void write(int b)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] buf)
throws IOException
write in class OutputStreamIOExceptionpublic void write(byte[] buf,
int off,
int siz)
throws IOException
write in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void writeToCopy(byte[] buf,
int off,
int siz)
throws SQLException
CopyInwriteToCopy in interface CopyInbuf - array of bytes to writeoff - offset of first byte to write (normally zero)siz - number of bytes to write (normally buf.length)SQLException - if the operation failspublic void writeToCopy(ByteStreamWriter from) throws SQLException
CopyInwriteToCopy in interface CopyInfrom - the source of bytes, e.g. a ByteBufferByteStreamWriterSQLException - if the operation failspublic int getFormat()
getFormat in interface CopyOperationpublic int getFieldFormat(int field)
getFieldFormat in interface CopyOperationfield - number of field (0..fieldCount()-1)public void cancelCopy()
throws SQLException
CopyOperationcancelCopy in interface CopyOperationSQLException - if cancelling failspublic int getFieldCount()
getFieldCount in interface CopyOperationpublic boolean isActive()
isActive in interface CopyOperationpublic void flushCopy()
throws SQLException
CopyInflushCopy in interface CopyInSQLException - if the operation fails.public long endCopy()
throws SQLException
CopyInendCopy in interface CopyInSQLException - if the operation fails.public long getHandledRowCount()
CopyOperationgetHandledRowCount in interface CopyOperationCopyright © 1997-2020 PostgreSQL Global Development Group. All Rights Reserved.