パッケージ org.postgresql.copy

クラス PGCopyOutputStream

java.lang.Object
java.io.OutputStream
org.postgresql.copy.PGCopyOutputStream
すべての実装されたインタフェース:
Closeable, Flushable, AutoCloseable, CopyIn, CopyOperation

public class PGCopyOutputStream extends OutputStream implements CopyIn
OutputStream for buffered input into a PostgreSQL COPY FROM STDIN operation.
  • コンストラクタの詳細

    • PGCopyOutputStream

      public PGCopyOutputStream(PGConnection connection, String sql) throws SQLException
      Uses given connection for specified COPY FROM STDIN operation.
      パラメータ:
      connection - database connection to use for copying (protocol version 3 required)
      sql - COPY FROM STDIN statement
      例外:
      SQLException - if initializing the operation fails
    • PGCopyOutputStream

      public PGCopyOutputStream(PGConnection connection, String sql, int bufferSize) throws SQLException
      Uses given connection for specified COPY FROM STDIN operation.
      パラメータ:
      connection - database connection to use for copying (protocol version 3 required)
      sql - COPY FROM STDIN statement
      bufferSize - try to send this many bytes at a time
      例外:
      SQLException - if initializing the operation fails
    • PGCopyOutputStream

      public PGCopyOutputStream(CopyIn op)
      Use given CopyIn operation for writing.
      パラメータ:
      op - COPY FROM STDIN operation
    • PGCopyOutputStream

      public PGCopyOutputStream(CopyIn op, int bufferSize)
      Use given CopyIn operation for writing.
      パラメータ:
      op - COPY FROM STDIN operation
      bufferSize - try to send this many bytes at a time
  • メソッドの詳細

    • write

      public void write(int b) throws IOException
      定義:
      write クラス内 OutputStream
      例外:
      IOException
    • write

      public void write(byte[] buf) throws IOException
      オーバーライド:
      write クラス内 OutputStream
      例外:
      IOException
    • write

      public void write(byte[] buf, int off, int siz) throws IOException
      オーバーライド:
      write クラス内 OutputStream
      例外:
      IOException
    • close

      public void close() throws IOException
      定義:
      close インタフェース内 AutoCloseable
      定義:
      close インタフェース内 Closeable
      オーバーライド:
      close クラス内 OutputStream
      例外:
      IOException
    • flush

      public void flush() throws IOException
      定義:
      flush インタフェース内 Flushable
      オーバーライド:
      flush クラス内 OutputStream
      例外:
      IOException
    • writeToCopy

      public void writeToCopy(byte[] buf, int off, int siz) throws SQLException
      インタフェースからコピーされた説明: CopyIn
      Writes specified part of given byte array to an open and writable copy operation.
      定義:
      writeToCopy インタフェース内 CopyIn
      パラメータ:
      buf - array of bytes to write
      off - offset of first byte to write (normally zero)
      siz - number of bytes to write (normally buf.length)
      例外:
      SQLException - if the operation fails
    • writeToCopy

      public void writeToCopy(ByteStreamWriter from) throws SQLException
      インタフェースからコピーされた説明: CopyIn
      Writes a ByteStreamWriter to an open and writable copy operation.
      定義:
      writeToCopy インタフェース内 CopyIn
      パラメータ:
      from - the source of bytes, e.g. a ByteBufferByteStreamWriter
      例外:
      SQLException - if the operation fails
    • getFormat

      public int getFormat()
      定義:
      getFormat インタフェース内 CopyOperation
      戻り値:
      overall format of each row: 0 = textual, 1 = binary
    • getFieldFormat

      public int getFieldFormat(int field)
      定義:
      getFieldFormat インタフェース内 CopyOperation
      パラメータ:
      field - number of field (0..fieldCount()-1)
      戻り値:
      format of requested field: 0 = textual, 1 = binary
    • cancelCopy

      public void cancelCopy() throws SQLException
      インタフェースからコピーされた説明: CopyOperation
      Cancels this copy operation, discarding any exchanged data.
      定義:
      cancelCopy インタフェース内 CopyOperation
      例外:
      SQLException - if cancelling fails
    • getFieldCount

      public int getFieldCount()
      定義:
      getFieldCount インタフェース内 CopyOperation
      戻り値:
      number of fields in each row for this operation
    • isActive

      public boolean isActive()
      定義:
      isActive インタフェース内 CopyOperation
      戻り値:
      is connection reserved for this Copy operation?
    • flushCopy

      public void flushCopy() throws SQLException
      インタフェースからコピーされた説明: CopyIn
      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.
      定義:
      flushCopy インタフェース内 CopyIn
      例外:
      SQLException - if the operation fails.
    • endCopy

      public long endCopy() throws SQLException
      インタフェースからコピーされた説明: CopyIn
      Finishes copy operation successfully.
      定義:
      endCopy インタフェース内 CopyIn
      戻り値:
      number of updated rows for server 8.2 or newer (see getHandledRowCount())
      例外:
      SQLException - if the operation fails.
    • getHandledRowCount

      public long getHandledRowCount()
      インタフェースからコピーされた説明: CopyOperation
      After successful end of copy, returns the number of database records handled in that operation. Only implemented in PostgreSQL server version 8.2 and up. Otherwise, returns -1.
      定義:
      getHandledRowCount インタフェース内 CopyOperation
      戻り値:
      number of handled rows or -1