oracle blob突破上限32k,Insert BLOB problem

在尝试使用Oracle JDBC thin client驱动插入BLOB数据时遇到错误。问题包括:1)无法从表中选择二进制数据;2)在执行插入操作时抛出异常(ORA-22990)。代码示例显示了插入过程,但最后一行执行查询时出现异常。错误堆栈显示LOB定位器不能跨越事务。寻求关于BLOB数据类型插入和查询的示例。
摘要由CSDN通过智能技术生成

Hello,

I would like to insert a binary data into the table.

I have the following problems:

1) How can I select binary data from table?

(I have try execute select statement in the SQL plus, but

it return error)

2) I have used the oracle JDBC thin client driver to insert a

binary data into table, the code as follow:

=================================================================

byte [] testData = "this is some test

data".getBytes();

Class.forName("oracle.jdbc.driver.OracleDriver");

conn = DriverManager.getConnection

("jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =

(PROTOCOL = TCP)(HOST = 192.168.0.xx)(PORT = 1521)) )

(CONNECT_DATA = (SERVICE_NAME = xxx) ) )","xxx","xxx");

BLOB b1 = new BLOB((OracleConnection)

conn,testData);

PreparedStatement stmt = conn.prepareStatement

("insert into testdata (id,data) values (?,?)");

stmt.setString(1,"1");

stmt.setBlob(2, b1);

stmt.executeQuery(); // throw the exception at

that line

stmt.close();

conn.close();

=================================================================

I have got the following exception:

=================================================================

java.sql.SQLException: ORA-22990: LOB locators cannot span

transactions

at oracle.jdbc.dbaccess.DBError.throwSqlException

(DBError.java:114)

at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)

at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:542)

at oracle.jdbc.ttc7.TTC7Protocol.doOall7

(TTC7Protocol.java:1311)

at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch

(TTC7Protocol.java:738)

at oracle.jdbc.driver.OracleStatement.executeNonQuery

(OracleStatement.java:1313)

at oracle.jdbc.driver.OracleStatement.doExecuteOther

(OracleStatement.java:1232)

at oracle.jdbc.driver.OracleStatement.doExecuteWithBatch

(OracleStatement.java:1353)

at oracle.jdbc.driver.OracleStatement.doExecute

(OracleStatement.java:1760)

at

oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout

(OracleStatement.java:1805)

at

oracle.jdbc.driver.OraclePreparedStatement.executeUpdate

(OraclePreparedStatement.java:322)

at

oracle.jdbc.driver.OraclePreparedStatement.executeQuery

(OraclePreparedStatement.java:280)

at com.kit.db.InstanceDB2.main(InstanceDB2.java:54)

================================================================

What wrong of my code?

3) Could you mind send me some example about the insert and

select of BLOB data type?

Thank you very much

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值