Reputation: 13666
Hi I am trying to do batch upload to sybase iq using JDBC prepared statements. I am getting the following sql exception
java.sql.SQLException: JZ0SA: Prepared Statement: Input parameter not set, index: 1.
EDIT:
INSERT INTO School2(schoolid,schoolname,schooltype) VALUES (?,?,?)
I am using the following code
I am new to JDBC please guide what is wrong. Thanks in advance.
Upvotes: 0
Views: 10438
Reputation: 9705
I think the problem is caused by the fact that you call pstmt.addBatch()
and pstmt.executeBatch()
for every iteration over colArray
. You should only call pstmt.addBatch()
after you have set all query parameters, and only call pstmt.executeBatch()
once all objects have been processed (or you've reached your batch size).
Upvotes: 1
Reputation: 53809
We do not see your query string but it seems that all the parameters are not set when you execute the statement.
Specifically, I don't think pstmt.executeBatch();
should be found in your for-loop setting the parameters: you execute the batch before setting all the parameters!
Upvotes: 2