Top Description Fields Constructors Methods
org.postgresql.core.v3

public Class CopyInImpl

extends CopyOperationImpl
implements CopyIn
Class Inheritance
All Implemented Interfaces
org.postgresql.copy.CopyIn, org.postgresql.copy.CopyOperation
Imports
org.postgresql.copy.CopyIn, org.postgresql.util.ByteStreamWriter, .GT, .PSQLException, .PSQLState, java.sql.SQLException

COPY FROM STDIN operation.

Anticipated flow: CopyManager.copyIn() ->QueryExecutor.startCopy() - sends given query to server ->processCopyResults(): - receives CopyInResponse from Server - creates new CopyInImpl ->initCopy(): - receives copy metadata from server ->CopyInImpl.init() ->lock() connection for this operation - if query fails an exception is thrown - if query returns wrong CopyOperation, copyIn() cancels it before throwing exception <-return: new CopyInImpl holding lock on connection repeat CopyIn.writeToCopy() for all data ->CopyInImpl.writeToCopy() ->QueryExecutorImpl.writeToCopy() - sends given data ->processCopyResults() - parameterized not to block, just peek for new messages from server - on ErrorResponse, waits until protocol is restored and unlocks connection CopyIn.endCopy() ->CopyInImpl.endCopy() ->QueryExecutorImpl.endCopy() - sends CopyDone - processCopyResults() - on CommandComplete ->CopyOperationImpl.handleCommandComplete() - sets updatedRowCount when applicable - on ReadyForQuery unlock() connection for use by other operations <-return: CopyInImpl.getUpdatedRowCount()

Field Summary

Inherited from org.postgresql.core.v3.CopyOperationImpl:
fieldFormatshandledRowCountqueryExecutorrowFormat

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long
endCopy()

Implements org.postgresql.copy.CopyIn.endCopy.

Finishes copy operation successfully.

public void
flushCopy()

Implements org.postgresql.copy.CopyIn.flushCopy.

Force any buffered output to be sent over the network to the backend.

protected void
handleCopydata(byte[]
data that was receive by copy protocol
data
)

Implements abstract org.postgresql.core.v3.CopyOperationImpl.handleCopydata.

Consume received copy data.

public void
writeToCopy(byte[]
array of bytes to write
data
,
int
offset of first byte to write (normally zero)
off
,
int
number of bytes to write (normally buf.length)
siz
)

Implements org.postgresql.copy.CopyIn.writeToCopy.

Writes specified part of given byte array to an open and writable copy operation.

public void
writeToCopy(ByteStreamWriter
the source of bytes, e.g. a ByteBufferByteStreamWriter
from
)

Implements org.postgresql.copy.CopyIn.writeToCopy.

Writes a ByteStreamWriter to an open and writable copy operation.

Inherited from org.postgresql.core.v3.CopyOperationImpl:
cancelCopygetFieldCountgetFieldFormatgetFormatgetHandledRowCountgetQueryExecutorhandleCommandStatusinitisActive

Constructor Detail

CopyInImplback to summary
public CopyInImpl()

Method Detail

endCopyback to summary
public long endCopy() throws SQLException

Implements org.postgresql.copy.CopyIn.endCopy.

Doc from org.postgresql.copy.CopyIn.endCopy.

Finishes copy operation successfully.

Returns:long

number of updated rows for server 8.2 or newer (see getHandledRowCount())

Annotations
@Override
Exceptions
SQLException:
if the operation fails.
flushCopyback to summary
public void flushCopy() throws SQLException

Implements org.postgresql.copy.CopyIn.flushCopy.

Doc from org.postgresql.copy.CopyIn.flushCopy.

Force any buffered output to be sent over the network to the backend. In general this is a useless operation as it will get pushed over in due time or when endCopy is called. Some specific modified server versions (Truviso) want this data sooner. If you are unsure if you need to use this method, don't.

Annotations
@Override
Exceptions
SQLException:
if the operation fails.
handleCopydataback to summary
protected void handleCopydata(byte[] data) throws PSQLException

Implements abstract org.postgresql.core.v3.CopyOperationImpl.handleCopydata.

Doc from org.postgresql.core.v3.CopyOperationImpl.handleCopydata.

Consume received copy data.

Parameters
data:byte[]

data that was receive by copy protocol

Annotations
@Override
Exceptions
PSQLException:
if some internal problem occurs
writeToCopyback to summary
public void writeToCopy(byte[] data, int off, int siz) throws SQLException

Implements org.postgresql.copy.CopyIn.writeToCopy.

Doc from org.postgresql.copy.CopyIn.writeToCopy.

Writes specified part of given byte array to an open and writable copy operation.

Parameters
data:byte[]

array of bytes to write

off:int

offset of first byte to write (normally zero)

siz:int

number of bytes to write (normally buf.length)

Annotations
@Override
Exceptions
SQLException:
if the operation fails
writeToCopyback to summary
public void writeToCopy(ByteStreamWriter from) throws SQLException

Implements org.postgresql.copy.CopyIn.writeToCopy.

Doc from org.postgresql.copy.CopyIn.writeToCopy.

Writes a ByteStreamWriter to an open and writable copy operation.

Parameters
from:ByteStreamWriter

the source of bytes, e.g. a ByteBufferByteStreamWriter

Annotations
@Override
Exceptions
SQLException:
if the operation fails