在jdbc中创建一个随机Blob并将其写入oracle [英] creating a random blob in jdbc and writing it to oracle

查看:139
本文介绍了在jdbc中创建一个随机Blob并将其写入oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在[内存中]的java中创建许多blob,并将其写入Oracle表.

I want to create many blobs in java [in memory] and write it to Oracle table.

我想要的是blob [其中的位]是随机的还是sudo随机的,因此oracle在将blob存储到表中时将无法进行很多预优化.

What I want is the blob[bits inside it] to be random or sudo random so that oracle would not be able to do a lot of pre-optimization while storing the blob to the table.

类似

for(1..1000000)
{
blob = createRandomBlob(sizeOfBlob);
sqlText ="INSERT INTO test_blob (id, blob) VALUES(i, blob)";
stmt.executeUpdate(sqlText);
}

有人可以指出我可以使用哪些JAVA API在内存中(而不是在磁盘上)创建此类blob并将其写入db吗?

Can someone point what JAVA APIs I can use to create such blob[in memory rather than on disk] and write it to db ?

谢谢

推荐答案

我只能回答将其存储在数据库部分中",不确定创建随机blob数组)

I can only answer for the "store it in the DB part", not sure about the "create a random blob array)


byte[] someBlob = createBlobBytes();
PreparedStatement stmt = connection.prepareStatement("INSERT INTO test_blob (id, blob) VALUES(?, ?)";
ByteArrayInputStream in = new ByteArrayInputStream(someBlob);
stmt.setInt(1, id);
stmt.setBinaryStream(2, in, someBlob.length);
stmt.executeUpdate();

这对于10.x驱动程序应该可以正常工作

This should work fine with the 10.x drivers

这篇关于在jdbc中创建一个随机Blob并将其写入oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆