Hi Friends,
I am new to this Forum, and I amd facing a stange problem while executing batch of SQL staments using PreparedStatement.executeBatch().
For Example : I have 2 rows to be inserted into DB2. if I insert the 2 rows one by one my code is inserting the data properly.
Where as if I use PreparedStatement.addBatch() and call preparedStatement.executeBatch(), the code is failing .
Here is my code:
...................
PreparedStatement pstmt = con.prepareStatement("SQL Query Here");
pstmt.setString(1, "adfdfd");
pstmt.setString(2, "dfghdfg");
pstmt.setString(3, "rtyrhj");
pstmt.addBatch();
pstmt.setString(1, "Rajesh");
pstmt.setString(2, "V");
pstmt.setString(3, "678");
pstmt.addBatch();
int[] a = pstmt.execuetBatch();
The error message i am getting is :
com.ibm.db2.jcc.b.vd: Non-atomic batch failure. The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements.
Error Code : -301
Message : Error for batch element #0: DB2 SQL error: SQLCODE: -301, SQLSTATE: 42895, SQLERRMC: 4
I'm using DB2 on windows:
JDBC Driver Details:
MajorVersion : 9
ProductVersion : DSN09015
DriverMajorVersion : 2
MinorVersion : 3
DriverName : IBM DB2 JDBC Universal Driver Architecture
Any Help is really appreciated.
Thanks in Advance!
Rajesh