Package org.postgresql.copy
Class CopyManager
- java.lang.Object
-
- org.postgresql.copy.CopyManager
-
public class CopyManager extends java.lang.Object
API for PostgreSQL COPY bulk data transfer.
-
-
Constructor Summary
Constructors Constructor Description CopyManager(BaseConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CopyDual
copyDual(java.lang.String sql)
CopyIn
copyIn(java.lang.String sql)
long
copyIn(java.lang.String sql, java.io.InputStream from)
Use COPY FROM STDIN for very fast copying from an InputStream into a database table.long
copyIn(java.lang.String sql, java.io.InputStream from, int bufferSize)
Use COPY FROM STDIN for very fast copying from an InputStream into a database table.long
copyIn(java.lang.String sql, java.io.Reader from)
Use COPY FROM STDIN for very fast copying from a Reader into a database table.long
copyIn(java.lang.String sql, java.io.Reader from, int bufferSize)
Use COPY FROM STDIN for very fast copying from a Reader into a database table.long
copyIn(java.lang.String sql, ByteStreamWriter from)
Use COPY FROM STDIN for very fast copying from an ByteStreamWriter into a database table.CopyOut
copyOut(java.lang.String sql)
long
copyOut(java.lang.String sql, java.io.OutputStream to)
Pass results of a COPY TO STDOUT query from database into an OutputStream.long
copyOut(java.lang.String sql, java.io.Writer to)
Pass results of a COPY TO STDOUT query from database into a Writer.
-
-
-
Constructor Detail
-
CopyManager
public CopyManager(BaseConnection connection) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
-
Method Detail
-
copyIn
public CopyIn copyIn(java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
copyOut
public CopyOut copyOut(java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
copyDual
public CopyDual copyDual(java.lang.String sql) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
copyOut
public long copyOut(java.lang.String sql, java.io.Writer to) throws java.sql.SQLException, java.io.IOException
Pass results of a COPY TO STDOUT query from database into a Writer.- Parameters:
sql
- COPY TO STDOUT statementto
- the Writer to write the results to (row by row). The Writer is not closed at the end of the Copy Out operation.- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage errorsjava.io.IOException
- upon writer or database connection failure
-
copyOut
public long copyOut(java.lang.String sql, java.io.OutputStream to) throws java.sql.SQLException, java.io.IOException
Pass results of a COPY TO STDOUT query from database into an OutputStream.- Parameters:
sql
- COPY TO STDOUT statementto
- the stream to write the results to (row by row) The stream is not closed at the end of the operation. This is intentional so the caller can continue to write to the output stream- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage errorsjava.io.IOException
- upon output stream or database connection failure
-
copyIn
public long copyIn(java.lang.String sql, java.io.Reader from) throws java.sql.SQLException, java.io.IOException
Use COPY FROM STDIN for very fast copying from a Reader into a database table.- Parameters:
sql
- COPY FROM STDIN statementfrom
- a CSV file or such- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage issuesjava.io.IOException
- upon reader or database connection failure
-
copyIn
public long copyIn(java.lang.String sql, java.io.Reader from, int bufferSize) throws java.sql.SQLException, java.io.IOException
Use COPY FROM STDIN for very fast copying from a Reader into a database table.- Parameters:
sql
- COPY FROM STDIN statementfrom
- a CSV file or suchbufferSize
- number of characters to buffer and push over network to server at once- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage issuesjava.io.IOException
- upon reader or database connection failure
-
copyIn
public long copyIn(java.lang.String sql, java.io.InputStream from) throws java.sql.SQLException, java.io.IOException
Use COPY FROM STDIN for very fast copying from an InputStream into a database table.- Parameters:
sql
- COPY FROM STDIN statementfrom
- a CSV file or such- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage issuesjava.io.IOException
- upon input stream or database connection failure
-
copyIn
public long copyIn(java.lang.String sql, java.io.InputStream from, int bufferSize) throws java.sql.SQLException, java.io.IOException
Use COPY FROM STDIN for very fast copying from an InputStream into a database table.- Parameters:
sql
- COPY FROM STDIN statementfrom
- a CSV file or suchbufferSize
- number of bytes to buffer and push over network to server at once- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage issuesjava.io.IOException
- upon input stream or database connection failure
-
copyIn
public long copyIn(java.lang.String sql, ByteStreamWriter from) throws java.sql.SQLException, java.io.IOException
Use COPY FROM STDIN for very fast copying from an ByteStreamWriter into a database table.- Parameters:
sql
- COPY FROM STDIN statementfrom
- the source of bytes, e.g. a ByteBufferByteStreamWriter- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
java.sql.SQLException
- on database usage issuesjava.io.IOException
- upon input stream or database connection failure
-
-