0

I'm not really sure about the mixing JDBC and Oracle batching... I read that I can't mix it on one instance of preparedStatment ... because of: Oracle Update Batching Models - Using both batching models in same application

But I also find something saying that it can't be mixed even in a single application... http://docs.oracle.com/cd/B10500_01/java.920/a96654/oraperf.htm

So know I'm not sure where the problem is...

I create a new prepared statment in each call of function:

public void functionCall(int Id)

    PreparedStatement insStm = null;
    String featureName = "";
    String featureTypeName = "";

        String sql = "BEGIN insert into " + TABLE_FEATURE_INSET + " values (?, ?, ?, ?); EXCEPTION WHEN others THEN IF SQLCODE != -1 THEN RAISE; END IF; END;";
        insStm = getConnection().prepareStatement(sql);

        for(xxx)
            for (yyy) {
                for (zzz) {
                    insStm.setObject(1, TypeName);
                    insStm.setObject(2, tableName);
                    insStm.setObject(3, sourceId);
                    insStm.setObject(4, Id);
                    insStm.addBatch();
                }
            }

            // per feature
            insStm.executeBatch();
        }
        statement .close();
}

And then I sometimes get an error...:

Caused by: java.sql.SQLException: operation not allowed: operation cannot be mixed with Oracle-style batching

Maybe is problem that prepareStatment can be from same connection? I'm really not sure about this.

Can somebody help me? Thanks

EDIT: That error is caused by this call: insStm.addBatch();

Community
  • 1
  • 1
Dusan Plavak
  • 4,457
  • 4
  • 24
  • 35
  • Did you use `((OracleConnection)conn).setDefaultExecuteBatch(..)` on your connection (or connection property `defaultBatchValue` or similar properties in the datasource)? That will disallow JDBC standard batching, and uses some kind of internal batching mechanism specific to the Oracle driver. – Mark Rotteveel Jul 23 '13 at 19:41
  • Yes, we used something like that... So that can cause an error? But I can use ((OracleConnection)conn).setDefaultExecuteBatch(..) and then on some other connection conn2 do a jdbc standard batching whithout a problem right? – Dusan Plavak Jul 24 '13 at 08:23
  • Yes that is the cause, Oracle batching and JDBC standard batching are mutually exclusive. If you have a connection where you don't use Oracle batching (the value is not explicitly set or set to 1), then you can use standard batching. – Mark Rotteveel Jul 24 '13 at 08:40

0 Answers0