/** * Uses given connection for specified COPY TO STDOUT operation. * * @param connection database connection to use for copying (protocol version 3 required) * @param sql COPY TO STDOUT statement * @throws SQLException if initializing the operation fails */ public PGCopyInputStream(PGConnection connection, String sql) throws SQLException { this(connection.getCopyAPI().copyOut(sql)); }
/** * Uses given connection for specified COPY TO STDOUT operation * @param connection database connection to use for copying (protocol version 3 required) * @param sql COPY TO STDOUT statement * @throws SQLException if initializing the operation fails */ public PGCopyInputStream(PGConnection connection, String sql) throws SQLException { this(connection.getCopyAPI().copyOut(sql)); }
/** * Pass results of a COPY TO STDOUT query from database into an OutputStream. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon output stream or database connection failure */ public long copyOut(final String sql, OutputStream to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while( (buf = cp.readFromCopy()) != null ) { to.write(buf); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
/** * Pass results of a COPY TO STDOUT query from database into a Writer. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon writer or database connection failure */ public long copyOut(final String sql, Writer to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while ( (buf = cp.readFromCopy()) != null ) { to.write(encoding.decode(buf)); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
CopyOut cp = copyOut(sql); try { while ((buf = cp.readFromCopy()) != null) {
CopyOut cp = copyOut(sql); try { while ((buf = cp.readFromCopy()) != null) {
/** * Uses given connection for specified COPY TO STDOUT operation * @param connection database connection to use for copying (protocol version 3 required) * @param sql COPY TO STDOUT statement * @throws SQLException if initializing the operation fails */ public PGCopyInputStream(PGConnection connection, String sql) throws SQLException { this(connection.getCopyAPI().copyOut(sql)); }
/** * Uses given connection for specified COPY TO STDOUT operation * @param connection database connection to use for copying (protocol version 3 required) * @param sql COPY TO STDOUT statement * @throws SQLException if initializing the operation fails */ public PGCopyInputStream(PGConnection connection, String sql) throws SQLException { this(connection.getCopyAPI().copyOut(sql)); }
tableLoadResult.rowCount = (int) copyManager.copyOut(copySql, protectedOut); if (tableLoadResult.rowCount == 0) {
if ("STDOUT".equals(std)){ if (output instanceof Writer){ result= copyManager.copyOut(sql, (Writer)output); }else if (output instanceof OutputStream){ result= copyManager.copyOut(sql, (OutputStream)output); } else{ result= copyManager.copyOut(sql, System.out); CopyOut copyOut= copyManager.copyOut(sql); result=copyOut.getHandledRowCount();
/** * Pass results of a COPY TO STDOUT query from database into an OutputStream. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon output stream or database connection failure */ public long copyOut(final String sql, OutputStream to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while( (buf = cp.readFromCopy()) != null ) { to.write(buf); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
/** * Pass results of a COPY TO STDOUT query from database into an OutputStream. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon output stream or database connection failure */ public long copyOut(final String sql, OutputStream to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while( (buf = cp.readFromCopy()) != null ) { to.write(buf); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
/** * Pass results of a COPY TO STDOUT query from database into a Writer. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon writer or database connection failure */ public long copyOut(final String sql, Writer to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while ( (buf = cp.readFromCopy()) != null ) { to.write(encoding.decode(buf)); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
/** * Pass results of a COPY TO STDOUT query from database into a Writer. * @param sql COPY TO STDOUT statement * @param to the stream to write the results to (row by row) * @return number of rows updated for server 8.2 or newer; -1 for older * @throws SQLException on database usage errors * @throws IOException upon writer or database connection failure */ public long copyOut(final String sql, Writer to) throws SQLException, IOException { byte[] buf; CopyOut cp = copyOut(sql); try { while ( (buf = cp.readFromCopy()) != null ) { to.write(encoding.decode(buf)); } return cp.getHandledRowCount(); } finally { // see to it that we do not leave the connection locked if(cp.isActive()) cp.cancelCopy(); } }
pgCon.getCopyAPI().copyOut(sql, resource.getOutputStream());