java.sql.Clob.setAsciiStream()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(271)

本文整理了Java中java.sql.Clob.setAsciiStream()方法的一些代码示例,展示了Clob.setAsciiStream()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Clob.setAsciiStream()方法的具体详情如下:
包路径:java.sql.Clob
类名称:Clob
方法名:setAsciiStream

Clob.setAsciiStream介绍

[英]Retrieves a stream which can be used to write Ascii characters to this Clob object, starting at specified position.
[中]从指定位置开始检索可用于将Ascii字符写入此Clob对象的流。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public void setClobAsAsciiStream(
    PreparedStatement ps, int paramIndex, @Nullable InputStream asciiStream, int contentLength)
    throws SQLException {
  if (asciiStream != null) {
    Clob clob = ps.getConnection().createClob();
    try {
      FileCopyUtils.copy(asciiStream, clob.setAsciiStream(1));
    }
    catch (IOException ex) {
      throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
    }
    this.temporaryClobs.add(clob);
    ps.setClob(paramIndex, clob);
  }
  else {
    ps.setClob(paramIndex, (Clob) null);
  }
  if (logger.isDebugEnabled()) {
    logger.debug(asciiStream != null ?
        "Copied ASCII stream into temporary CLOB with length " + contentLength :
        "Set CLOB to null");
  }
}

代码示例来源:origin: alibaba/druid

@Override
public void setClobAsAsciiStream(PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength)
                                                         throws SQLException {
  if (asciiStream != null) {
    Clob clob = ps.getConnection().createClob();
    OutputStream out = clob.setAsciiStream(1);
    final int BUFFER_SIZE = 4096;
    try {
      byte[] buffer = new byte[BUFFER_SIZE];
      int bytesRead = -1;
      while ((bytesRead = asciiStream.read(buffer)) != -1) {
        out.write(buffer, 0, bytesRead);
      }
      out.flush();
    } catch (Exception e) {
      throw new SQLException("setClob error", e);
    } finally {
      JdbcUtils.close(asciiStream);
      JdbcUtils.close(out);
    }
    ps.setClob(paramIndex, clob);
  } else {
    ps.setClob(paramIndex, (Clob) null);
  }
}

代码示例来源:origin: alibaba/druid

@Override
public java.io.OutputStream clob_setAsciiStream(ClobProxy clob, long pos) throws SQLException {
  if (this.pos < filterSize) {
    return nextFilter().clob_setAsciiStream(this, clob, pos);
  }
  return clob.getRawClob().setAsciiStream(pos);
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public Clob mergeClob(Clob original, Clob target, SharedSessionContractImplementor session) {
  if ( original != target ) {
    try {
      // the CLOB just read during the load phase of merge
      final OutputStream connectedStream = target.setAsciiStream( 1L );
      // the CLOB from the detached state
      final InputStream detachedStream = original.getAsciiStream();
      StreamCopier.copy( detachedStream, connectedStream );
      return target;
    }
    catch (SQLException e ) {
      throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
    }
  }
  else {
    return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeClob( original, target, session );
  }
}

代码示例来源:origin: com.alibaba/druid

@Override
public void setClobAsAsciiStream(PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength)
                                                         throws SQLException {
  if (asciiStream != null) {
    Clob clob = ps.getConnection().createClob();
    OutputStream out = clob.setAsciiStream(1);
    final int BUFFER_SIZE = 4096;
    try {
      byte[] buffer = new byte[BUFFER_SIZE];
      int bytesRead = -1;
      while ((bytesRead = asciiStream.read(buffer)) != -1) {
        out.write(buffer, 0, bytesRead);
      }
      out.flush();
    } catch (Exception e) {
      throw new SQLException("setClob error", e);
    } finally {
      JdbcUtils.close(asciiStream);
      JdbcUtils.close(out);
    }
    ps.setClob(paramIndex, clob);
  } else {
    ps.setClob(paramIndex, (Clob) null);
  }
}

代码示例来源:origin: com.alibaba/druid

@Override
public java.io.OutputStream clob_setAsciiStream(ClobProxy clob, long pos) throws SQLException {
  if (this.pos < filterSize) {
    return nextFilter().clob_setAsciiStream(this, clob, pos);
  }
  return clob.getRawClob().setAsciiStream(pos);
}

代码示例来源:origin: org.teiid/teiid-common-core

/** 
 * @see java.sql.Clob#setAsciiStream(long)
 */
public OutputStream setAsciiStream(long pos) throws SQLException {
  return this.reference.setAsciiStream(pos);
}

代码示例来源:origin: teiid/teiid

/** 
 * @see java.sql.Clob#setAsciiStream(long)
 */
public OutputStream setAsciiStream(long pos) throws SQLException {
  return this.reference.setAsciiStream(pos);
}

代码示例来源:origin: io.snappydata/gemfirexd-core

/**
 * {@inheritDoc}
 */
@Override
public OutputStream setAsciiStream(long pos) throws SQLException {
 return this.clob.setAsciiStream(pos);
}

代码示例来源:origin: io.snappydata/snappydata-store-core

/**
 * {@inheritDoc}
 */
@Override
public OutputStream setAsciiStream(long pos) throws SQLException {
 return this.clob.setAsciiStream(pos);
}

代码示例来源:origin: co.paralleluniverse/comsat-jdbc

@Override
  public OutputStream call() throws SQLException {
    return clob.setAsciiStream(pos);
  }
});

代码示例来源:origin: io.snappydata/gemfirexd

/**
 * {@inheritDoc}
 */
@Override
public OutputStream setAsciiStream(long pos) throws SQLException {
 return this.clob.setAsciiStream(pos);
}

代码示例来源:origin: liukaixuan/guzz

public OutputStream setAsciiStream(long pos) throws SQLException {
  return getWrappedClob().setAsciiStream(pos) ;
}

代码示例来源:origin: hibernate/hibernate

public OutputStream setAsciiStream(long pos) throws SQLException {
  return getWrappedClob().setAsciiStream(pos);
}

代码示例来源:origin: jboss.jboss-embeddable-ejb3/hibernate-all

public OutputStream setAsciiStream(long pos) throws SQLException {
  return getWrappedClob().setAsciiStream(pos);
}

代码示例来源:origin: org.springframework/org.springframework.jdbc

public void setClobAsAsciiStream(
    PreparedStatement ps, int paramIndex, InputStream asciiStream, int contentLength)
    throws SQLException {
  Clob clob = ps.getConnection().createClob();
  try {
    FileCopyUtils.copy(asciiStream, clob.setAsciiStream(1));
  }
  catch (IOException ex) {
    throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
  }
  this.temporaryClobs.add(clob);
  ps.setClob(paramIndex, clob);
  if (logger.isDebugEnabled()) {
    logger.debug(asciiStream != null ?
        "Copied ASCII stream into temporary CLOB with length " + contentLength :
        "Set CLOB to null");
  }
}

代码示例来源:origin: apache/servicemix-bundles

@Override
public void setClobAsAsciiStream(
    PreparedStatement ps, int paramIndex, @Nullable InputStream asciiStream, int contentLength)
    throws SQLException {
  if (asciiStream != null) {
    Clob clob = ps.getConnection().createClob();
    try {
      FileCopyUtils.copy(asciiStream, clob.setAsciiStream(1));
    }
    catch (IOException ex) {
      throw new DataAccessResourceFailureException("Could not copy into LOB stream", ex);
    }
    this.temporaryClobs.add(clob);
    ps.setClob(paramIndex, clob);
  }
  else {
    ps.setClob(paramIndex, (Clob) null);
  }
  if (logger.isDebugEnabled()) {
    logger.debug(asciiStream != null ?
        "Copied ASCII stream into temporary CLOB with length " + contentLength :
        "Set CLOB to null");
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate

@Override
public Clob mergeClob(Clob original, Clob target, SessionImplementor session) {
  if ( original != target ) {
    try {
      OutputStream connectedStream = target.setAsciiStream( 1L );  // the CLOB just read during the load phase of merge
      InputStream detachedStream = original.getAsciiStream();      // the CLOB from the detached state
      StreamCopier.copy( detachedStream, connectedStream );
      return target;
    }
    catch (SQLException e ) {
      throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
    }
  }
  else {
    return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeClob( original, target, session );
  }
}

代码示例来源:origin: org.hibernate/com.springsource.org.hibernate.core

@Override
public Clob mergeClob(Clob original, Clob target, SessionImplementor session) {
  if ( original != target ) {
    try {
      OutputStream connectedStream = target.setAsciiStream( 1L );  // the CLOB just read during the load phase of merge
      InputStream detachedStream = original.getAsciiStream();      // the CLOB from the detached state
      StreamCopier.copy( detachedStream, connectedStream );
      return target;
    }
    catch (SQLException e ) {
      throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
    }
  }
  else {
    return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeClob( original, target, session );
  }
}

代码示例来源:origin: org.hibernate.orm/hibernate-core

@Override
public Clob mergeClob(Clob original, Clob target, SharedSessionContractImplementor session) {
  if ( original != target ) {
    try {
      // the CLOB just read during the load phase of merge
      final OutputStream connectedStream = target.setAsciiStream( 1L );
      // the CLOB from the detached state
      final InputStream detachedStream = original.getAsciiStream();
      StreamCopier.copy( detachedStream, connectedStream );
      return target;
    }
    catch (SQLException e ) {
      throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge CLOB data" );
    }
  }
  else {
    return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeClob( original, target, session );
  }
}

相关文章