当前位置: 首页>>代码示例>>Java>>正文


Java Blob.setBinaryStream方法代码示例

本文整理汇总了Java中java.sql.Blob.setBinaryStream方法的典型用法代码示例。如果您正苦于以下问题:Java Blob.setBinaryStream方法的具体用法?Java Blob.setBinaryStream怎么用?Java Blob.setBinaryStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.sql.Blob的用法示例。


在下文中一共展示了Blob.setBinaryStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mergeBlob

import java.sql.Blob; //导入方法依赖的package包/类
@Override
public Blob mergeBlob(Blob original, Blob target, SessionImplementor session) {
	if ( original != target ) {
		try {
			// the BLOB just read during the load phase of merge
			final OutputStream connectedStream = target.setBinaryStream( 1L );
			// the BLOB from the detached state
			final InputStream detachedStream = original.getBinaryStream();
			StreamCopier.copy( detachedStream, connectedStream );
			return target;
		}
		catch (SQLException e ) {
			throw session.getFactory().getSQLExceptionHelper().convert( e, "unable to merge BLOB data" );
		}
	}
	else {
		return NEW_LOCATOR_LOB_MERGE_STRATEGY.mergeBlob( original, target, session );
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Dialect.java

示例2: setReplicationDataBlob

import java.sql.Blob; //导入方法依赖的package包/类
private static void setReplicationDataBlob ( final PreparedStatement stmt, final Event event ) throws SQLException, IOException
{
    final Blob blob = stmt.getConnection ().createBlob ();

    final ObjectOutputStream oos = new ObjectOutputStream ( blob.setBinaryStream ( 1 ) );
    oos.writeObject ( event );
    oos.close ();

    stmt.setBlob ( 4, blob );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:11,代码来源:AbstractJdbcStorageDao.java

示例3: doWriteDerby

import java.sql.Blob; //导入方法依赖的package包/类
private void doWriteDerby(Handle h, String id, InputStream file) {
    doDelete(h, id);
    try {
        Blob blob = h.getConnection().createBlob();
        try (OutputStream out = blob.setBinaryStream(1)) {
            IOUtils.copy(file, out);
        }

        h.insert("INSERT INTO icon_filestore(id, data) values (?,?)", id, blob);
    } catch (IOException | SQLException ex) {
        throw IconDataAccessException.launderThrowable(ex);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:SqlIconFileStore.java

示例4: doWriteDerby

import java.sql.Blob; //导入方法依赖的package包/类
private void doWriteDerby(Handle h, String path, InputStream file) {
    doDelete(h, path);
    try {
        Blob blob = h.getConnection().createBlob();
        try (OutputStream out = blob.setBinaryStream(1)) {
            IOUtils.copy(file, out);
        }

        h.insert("INSERT INTO filestore(path, data) values (?,?)", path, blob);
    } catch (IOException | SQLException ex) {
        throw ExtensionDataAccessException.launderThrowable(ex);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:14,代码来源:SqlExtensionFileStore.java

示例5: next

import java.sql.Blob; //导入方法依赖的package包/类
@Override
public Blob next() {
  try {
    Blob blob =
        (Blob) methCreateTemporary.invoke(null, conn, false, durationSession);

    int blobSize =
        (int) (rng.nextDouble() * (maxBytes - minBytes) + minBytes);
    byte[] blobData = new byte[blobSize];
    rng.nextBytes(blobData);

    // blob.setBytes(blobData);

    OutputStream os = blob.setBinaryStream(1);
    InputStream is = new ByteArrayInputStream(blobData);
    int bufferSize = (Integer) methGetBufferSize.invoke(blob);
    byte[] buffer = new byte[bufferSize];
    int bytesRead = 0;
    while ((bytesRead = is.read(buffer)) != -1) {
      os.write(buffer, 0, bytesRead);
    }
    os.close();
    is.close();

    return blob;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:30,代码来源:BlobGenerator.java


注:本文中的java.sql.Blob.setBinaryStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。