Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Ordered Prepared Statement Batch Execution

VivekSreeSep 27 2014 — edited Oct 15 2014

I have a basic requirement. We use the jdbc driver to connect to Oracle 11 Database.

We use the PreparedStament, to execute multiple statements in batches.

Following is the typical code snippet used:

          PreparedStatement stmt = connection.prepareStatement(SQL);

            for (ObjEntry param : rows) {

                stmt.setLong(IDX_TIME, param.getStartTime());

                stmt.setLong(IDX_BYTES, param.getBytes());

                stmt.setLong(IDX_ID, param.getDbId());

                stmt.addBatch();

            }

           

            stmt.executeBatch();

I know that the Batch will execute the commands, in the same order as that added to the Batch using the stmt.addBatch call.

However, I need the statements to be ordered in ascending order, based on the value of one of the fields,

say IDX_ID.

Is that possible?

This post has been answered by unknown-7404 on Sep 27 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 25 2014
Added on Sep 27 2014
1 comment
386 views