Examples of PGCopyInputStream


Examples of org.postgresql.copy.PGCopyInputStream

    }
   
    public void testReadBytesCorrectlyHandlesEof() throws SQLException, IOException {
      insertSomeData();
     
      sut = new PGCopyInputStream((PGConnection) _conn, "COPY cpinstreamtest (i) TO STDOUT WITH (FORMAT CSV, HEADER false)");
     
      byte[] buf = new byte[100]; // large enough to read everything on the next step
      assertTrue(sut.read(buf) > 0);
     
      assertEquals(-1, sut.read(buf));
View Full Code Here

Examples of org.postgresql.copy.PGCopyInputStream

    }

    public void testReadBytesCorrectlyReadsDataInChunks() throws SQLException, IOException {
      insertSomeData();
     
      sut = new PGCopyInputStream((PGConnection) _conn, "COPY (select i from cpinstreamtest order by i asc) TO STDOUT WITH (FORMAT CSV, HEADER false)");
     
      byte[] buf = new byte[2]; // small enough to read in multiple chunks
      StringBuilder result = new StringBuilder(100);
      int chunks = 0;
      while (sut.read(buf) > 0) {
View Full Code Here

Examples of org.postgresql.copy.PGCopyInputStream

    }
   
    public void testStreamCanBeClosedAfterReadUp() throws SQLException, IOException {
      insertSomeData();
     
      sut = new PGCopyInputStream((PGConnection) _conn, "COPY (select i from cpinstreamtest order by i asc) TO STDOUT WITH (FORMAT CSV, HEADER false)");
     
      byte[] buff = new byte[100];
    while(sut.read(buff) > 0);
   
    sut.close();
View Full Code Here

Examples of org.postgresql.copy.PGCopyInputStream

//    }    
  }
 
  @Override
  public void read(ILineSender lineSender){
    PGCopyInputStream inputStream = null;
    if(sql.isEmpty()){
      logger.error("Sql for GreenplumReader is empty.");
      throw new WormholeException("Sql for GreenplumReader is empty.",JobStatus.READ_FAILED.getStatus()+ERROR_CODE_ADD)
    }
    logger.info(String.format("GreenplumReader start to query %s .", sql));
    for(String sqlItem:sql.split(";")){
      sqlItem = sqlItem.trim();
      if(sqlItem.isEmpty()) {
        continue;
      }
      try {
        inputStream = new PGCopyInputStream((PGConnection) ((DelegatingConnection) conn).getInnermostDelegate(), sqlItem);
        fetchData(lineSender,inputStream);
      } catch (Exception e) {       
        logger.error("GreenplumReader error");
        WormholeException ex = new WormholeException(e,JobStatus.READ_FAILED.getStatus());
        if(e instanceof WormholeException) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.