public void close() throws IOException { // Don't complain about a double close. if (op == null) { return; } try { endCopy(); } catch (SQLException se) { IOException ioe = new IOException("Ending write to copy failed."); ioe.initCause(se); throw ioe; } op = null; }
public void write(int b) throws IOException { checkClosed(); if (b < 0 || b > 255) { throw new IOException(GT.tr("Cannot write to copy a byte of value {0}", b)); } singleByteBuffer[0] = (byte) b; write(singleByteBuffer, 0, 1); }
public long endCopy() throws SQLException { if (at > 0) { op.writeToCopy(copyBuffer, 0, at); } op.endCopy(); return getHandledRowCount(); }
public void write(byte[] buf, int off, int siz) throws IOException { checkClosed(); try { writeToCopy(buf, off, siz); } catch (SQLException se) { IOException ioe = new IOException("Write to copy failed."); ioe.initCause(se); throw ioe; } }
public void write(byte[] buf) throws IOException { write(buf, 0, buf.length); }
@Override protected void flushBacklogInternal() throws SQLException { try { // flush out nodes PGCopyOutputStream nodesOut = new PGCopyOutputStream(PGCopyUtil.getWrappedConnection(connection.getJDBCConnection()), "COPY nodes(id,ntype,svalue,dvalue,ivalue,tvalue,tzoffset,bvalue,ltype,lang,createdAt) FROM STDIN (FORMAT csv)"); PGCopyUtil.flushNodes(nodeBacklog, nodesOut); nodesOut.close(); // flush out triples PGCopyOutputStream triplesOut = new PGCopyOutputStream(PGCopyUtil.getWrappedConnection(connection.getJDBCConnection()), "COPY triples FROM STDIN (FORMAT csv)"); PGCopyUtil.flushTriples(tripleBacklog, triplesOut); triplesOut.close(); } catch (IOException ex) { throw new SQLException("error while flushing out data",ex); } }
private void do_copy( PGBulkLoaderMeta meta, boolean wait ) throws KettleException { data.db = getDatabase( this, meta ); String copyCmd = getCopyCommand(); try { connect(); checkClientEncoding(); processTruncate(); logBasic( "Launching command: " + copyCmd ); pgCopyOut = new PGCopyOutputStream( (PGConnection) data.db.getConnection(), copyCmd ); } catch ( Exception ex ) { throw new KettleException( "Error while preparing the COPY " + copyCmd, ex ); } }
public void write(byte[] buf, int off, int siz) throws IOException { checkClosed(); try { writeToCopy(buf, off, siz); } catch(SQLException se) { IOException ioe = new IOException("Write to copy failed."); ioe.initCause(se); throw ioe; } }
public void write(byte[] buf) throws IOException { write(buf, 0, buf.length); }
@Override protected void flushBacklogInternal() throws SQLException { try { // flush out nodes PGCopyOutputStream nodesOut = new PGCopyOutputStream(PGCopyUtil.getWrappedConnection(connection.getJDBCConnection()), "COPY nodes(id,ntype,svalue,dvalue,ivalue,tvalue,tzoffset,bvalue,ltype,lang,createdAt) FROM STDIN (FORMAT csv)"); PGCopyUtil.flushNodes(nodeBacklog, nodesOut); nodesOut.close(); // flush out triples PGCopyOutputStream triplesOut = new PGCopyOutputStream(PGCopyUtil.getWrappedConnection(connection.getJDBCConnection()), "COPY triples FROM STDIN (FORMAT csv)"); PGCopyUtil.flushTriples(tripleBacklog, triplesOut); triplesOut.close(); } catch (IOException ex) { throw new SQLException("error while flushing out data",ex); } }
public void write(int b) throws IOException { checkClosed(); if(b<0 || b>255) throw new IOException(GT.tr("Cannot write to copy a byte of value {0}", new Integer(b))); singleByteBuffer[0] = (byte)b; write(singleByteBuffer, 0, 1); }
public void write(byte[] buf, int off, int siz) throws IOException { checkClosed(); try { writeToCopy(buf, off, siz); } catch(SQLException se) { IOException ioe = new IOException("Write to copy failed."); ioe.initCause(se); throw ioe; } }
pgCopyOut.write( data.separator ); switch ( valueMeta.getType() ) { case ValueMetaInterface.TYPE_STRING: pgCopyOut.write( data.quote ); pgCopyOut.write( escapedString.getBytes( clientEncoding ) ); pgCopyOut.write( data.quote ); break; case ValueMetaInterface.TYPE_INTEGER: if ( valueMeta.isStorageBinaryString() ) { pgCopyOut.write( (byte[]) valueData ); } else { pgCopyOut.write( Long.toString( valueMeta.getInteger( valueData ) ).getBytes( clientEncoding ) ); pgCopyOut.write( (byte[]) valueData ); } else { String dateString = valueMeta.getString( valueData ); if ( dateString != null ) { pgCopyOut.write( dateString.getBytes( clientEncoding ) ); String dateString = data.dateMeta.getString( valueMeta.getDate( valueData ) ); if ( dateString != null ) { pgCopyOut.write( dateString.getBytes( clientEncoding ) ); String dateTimeString = data.dateTimeMeta.getString( valueMeta.getDate( valueData ) ); if ( dateTimeString != null ) { pgCopyOut.write( dateTimeString.getBytes( clientEncoding ) );
public void close() throws IOException { // Don't complain about a double close. if (op == null) return; try{ endCopy(); } catch(SQLException se) { IOException ioe = new IOException("Ending write to copy failed."); ioe.initCause(se); throw ioe; } op = null; }
public long endCopy() throws SQLException { if(at > 0) { op.writeToCopy(copyBuffer, 0, at); } op.endCopy(); return getHandledRowCount(); }
public void write(int b) throws IOException { checkClosed(); if(b<0 || b>255) throw new IOException(GT.tr("Cannot write to copy a byte of value {0}", new Integer(b))); singleByteBuffer[0] = (byte)b; write(singleByteBuffer, 0, 1); }
public void write(byte[] buf, int off, int siz) throws IOException { checkClosed(); try { writeToCopy(buf, off, siz); } catch(SQLException se) { IOException ioe = new IOException("Write to copy failed."); ioe.initCause(se); throw ioe; } }
public void write(byte[] buf) throws IOException { write(buf, 0, buf.length); }
public void close() throws IOException { // Don't complain about a double close. if (op == null) return; try{ endCopy(); } catch(SQLException se) { IOException ioe = new IOException("Ending write to copy failed."); ioe.initCause(se); throw ioe; } op = null; }