Hi
I have to insert multiple rows into a Table. I am inserting rows
using addBatch and executeBatch.
Each row has 5 columns. Four columns of each row contain
same value except last column.
So I am using for loop to set the last column value.
I am using JDK1.5, DB2 and WAS6.1. My connection is OK and setAutoCommit sets as false.
I am not getting any error message or exception but Nothing is inserted in
the table. I am not sure why data is not inserted in the table.
I would be glad if anyone kindly help me to solve this issue.
Thank you
I have to insert multiple rows into a Table. I am inserting rows
using addBatch and executeBatch.
Each row has 5 columns. Four columns of each row contain
same value except last column.
So I am using for loop to set the last column value.
I am using JDK1.5, DB2 and WAS6.1. My connection is OK and setAutoCommit sets as false.
Code:
String insertStr="INSERT INTO DB.TBLNAME (COL1, COL2, COL3,COL4,COL5) VALUES(?,?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(insertStr);
pstmt.setString(1, COL1);
pstmt.setString(2, COL2);
pstmt.setString(3, COL3);
pstmt.setString(4, COL4);
int counter[]=null;
for(int i=0; i<vector.size(); i++){
pstmt.setString(5, (String)vector.elementAt(i));
pstmt.addBatch();
counter=pstmt.executeBatch();
}
con.commit();
pstmt.close();
the table. I am not sure why data is not inserted in the table.
I would be glad if anyone kindly help me to solve this issue.
Thank you
Comment