Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting problem while inserting data into database by using executebatch

 
vijayz devraj
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
iam using beans here
iam storing the data in arrayList object and iterating it.

code:


while(xldataiterator.hasNext()){
pstmt = myConnection.prepareStatement("insert into xxxx values(?,?,?,?)");
pstmt.setString(1, xlformdataget.getEmail());

------
-----
-----
pstmt.addBatch(); ///adding to batch
}

int[] updateCounts = pstmt.executeBatch();
processUpdateCounts(updateCounts);
}

public static void processUpdateCounts(int[] updateCounts) {
for (int i=0; i<updateCounts.length; i++) {
if (updateCounts[i] >= 0)
s.o.p("Successfully executed; the number represents number of affected rows");
} else if (updateCounts[i] == Statement.SUCCESS_NO_INFO) {
s.o.p("Successfully executed; number of affected rows not available");
} else if (updateCounts[i] == Statement.EXECUTE_FAILED) {
s.o.p("Failed to execute");
} } }
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijayz,
I don't see the error in your post. What's wrong?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic