使用oracle prepare语句执行批处理 [英] execute batch with oracle prepared statement
问题描述
我尝试使用以下代码添加批处理准备好的语句:
I try to add batch prepared statement with following code:
Connection c = ...
PreparedStatement ps = c.prepareStatement(query1);
ps.setObject(....)
...
ps.addBatch(query2); // SqlException : Unsupported feature
oracle jdbc驱动程序不支持批处理吗,或者我做错了什么?
Does not oracle jdbc driver support batches, or I am doing something wrong?
我正在使用oracle瘦驱动程序.来自MANIFEST.MF Implementation-Version: 11.2.0.1.0
的版本.
I am using oracle thin driver. Version from MANIFEST.MF Implementation-Version: 11.2.0.1.0
.
java.sql.SQLException: Unsupported feature
at oracle.jdbc.driver.OraclePreparedStatement.addBatch(OraclePreparedStatement.java:9803)
at oracle.jdbc.driver.OracleStatementWrapper.addBatch(OracleStatementWrapper.java:285)
at org.jboss.resource.adapter.jdbc.WrappedStatement.addBatch(WrappedStatement.java:731)
at <application classes>
推荐答案
您正在使用query1
创建PreparedStatement
,并将query2
添加到不属于它的已经准备好的语句中.
You are creating a PreparedStatement
using query1
and adding query2
to an already prepared statetement of which it doesn't belong to.
如果您使用的是PreparedStatement
,建议您改用PreparedStatement.addBatch()
方法.
If you are using PreparedStatement
, I suggest using the PreparedStatement.addBatch()
method instead.
PreparedStatement ps = c.prepareStatement(query1);
ps.setObject(....);
ps.addBatch(); //Voila
这篇关于使用oracle prepare语句执行批处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!