There is a link for oracle batch, I use it in a project, like below:
PreparedStatement pstmt =
conn.prepareStatement("INSERT INTO user VALUES(?, ?)");
pstmt.setInt(1, 2);
pstmt.setString(2, "a");
pstmt.addBatch();
pstmt.setInt(1, 3);
//pstmt.setString(2, "b");
pstmt.addBatch();
The table has two fields, id and name. I don't set name the second time, but in the table there are still two records and names are both 'a'.
ojdbc version
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.2</version>
<scope>test</scope>
</dependency>
Is there anything wrong in my usage, or just ojdbc has a defect? Should I align the parameter before using the ojbdc batching?
ais still set from the first record. You could dobefore setting values for the 2nd record