I have a oracle stored proc
that needs to be called from my Java program. I had used CallableStatement
to pass parameters to the stored proc. I am
From your comment, you have prepareCall inside your loop. An advantage of prepared statements (and callable statements) is that you can prepare it once, and then swap out the values passed in the parameters; there is overhead each time the call is prepared, so if you could bring that outside of your loop, you may find that run time decreases. You may find that turning off AutoCommit also helps, as there is overhead with each commit.
conn.setAutoCommit(false);
CallableStatement stmt = conn.prepareCall(sql);
while(true) {
stmt.setInt(1, value);
stmt.execute();
}
conn.commit();
conn.setAutoCommit(true);
(conn.setAutoCommit(true)
does commit, but I find it clearer to be explicit).
Shouldn't you consider using batch?
conn.setAutoCommit(false);
CallableStatement stmt = conn.prepareCall(sql);
while(true) {
stmt.setInt(1, value);
stmt.addBatch();
}
stmt.executeBatch()
conn.commit();