Package org.postgresql.copy
Class CopyManager
- java.lang.Object
-
- org.postgresql.copy.CopyManager
-
public class CopyManager extends 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 CopyDualcopyDual(String sql)CopyIncopyIn(String sql)longcopyIn(String sql, InputStream from)Use COPY FROM STDIN for very fast copying from an InputStream into a database table.longcopyIn(String sql, InputStream from, int bufferSize)Use COPY FROM STDIN for very fast copying from an InputStream into a database table.longcopyIn(String sql, Reader from)Use COPY FROM STDIN for very fast copying from a Reader into a database table.longcopyIn(String sql, Reader from, int bufferSize)Use COPY FROM STDIN for very fast copying from a Reader into a database table.CopyOutcopyOut(String sql)longcopyOut(String sql, OutputStream to)Pass results of a COPY TO STDOUT query from database into an OutputStream.longcopyOut(String sql, Writer to)Pass results of a COPY TO STDOUT query from database into a Writer.
-
-
-
Constructor Detail
-
CopyManager
public CopyManager(BaseConnection connection) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
copyIn
public CopyIn copyIn(String sql) throws SQLException
- Throws:
SQLException
-
copyOut
public CopyOut copyOut(String sql) throws SQLException
- Throws:
SQLException
-
copyDual
public CopyDual copyDual(String sql) throws SQLException
- Throws:
SQLException
-
copyOut
public long copyOut(String sql, Writer to) throws SQLException, IOException
Pass results of a COPY TO STDOUT query from database into a Writer.- Parameters:
sql- COPY TO STDOUT statementto- the stream to write the results to (row by row)- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
SQLException- on database usage errorsIOException- upon writer or database connection failure
-
copyOut
public long copyOut(String sql, OutputStream to) throws SQLException, 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)- Returns:
- number of rows updated for server 8.2 or newer; -1 for older
- Throws:
SQLException- on database usage errorsIOException- upon output stream or database connection failure
-
copyIn
public long copyIn(String sql, Reader from) throws SQLException, 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:
SQLException- on database usage issuesIOException- upon reader or database connection failure
-
copyIn
public long copyIn(String sql, Reader from, int bufferSize) throws SQLException, 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:
SQLException- on database usage issuesIOException- upon reader or database connection failure
-
copyIn
public long copyIn(String sql, InputStream from) throws SQLException, 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:
SQLException- on database usage issuesIOException- upon input stream or database connection failure
-
copyIn
public long copyIn(String sql, InputStream from, int bufferSize) throws SQLException, 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:
SQLException- on database usage issuesIOException- upon input stream or database connection failure
-
-