當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。