public boolean isActive() { return op != null && op.isActive(); }
public boolean isActive() { return op.isActive(); }
public void close() throws IOException { // Don't complain about a double close. if (op == null) { return; } if (op.isActive()) { try { op.cancelCopy(); } catch (SQLException se) { IOException ioe = new IOException("Failed to close copy reader."); ioe.initCause(se); throw ioe; } } op = null; }
/** * 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(); } }
public boolean isActive() { return op.isActive(); }
public boolean isActive() { return op.isActive(); }
/** * 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(); } }