Thank you,
Now, I am very surprised that not all data is inserted into the table.
I wanted to insert 5 rows data, only last rows has been inserted into table.
PreparedStatement is not working
Collapse
X
-
-
What do you see when you print the 'counter' array obtained in line #15?
kind regards,
JosLeave a comment:
-
Hi,
Thank you
I set setAutoComit true and removed commit() from my code.
But still, no data is inserted into the table. I am very confused.Leave a comment:
-
You are checking it in another session.
Whenever you open a connection then a database session opens up, if the setAutoComit(fa lse) is done then the modified data reflected to that session only where you did the operations; otherwise the modified data reflected across all database session. If you check in same session then you must get the modified data.Leave a comment:
-
PreparedStatement is not working
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 inCode: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 youTags: None
Leave a comment: