• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

getting problem while inserting data into database by using executebatch  RSS feed

 
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");
} } }
 
author & internet detective
Posts: 39283
727
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?
 
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!