This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

how do i insert more than one row to my table

Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello there,
This is the code snippet iv written
but the problem is its not inserting all the items in the String object , its inserting only the first value i.e l[0] and kp[0]. What corrections should i make to insert all the elements of the String object
please let me know the corrections.
void insertResults(String l[],String kp[],String tName)throws Exception
String cmd="insert into "+tName+" values(?,?)";
PreparedStatement pst=null;
for(int i=0;i<kp.length;i++)

Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's nothing wrong with that that I can see, although clearParameters is unneeded; it should be harmless functionally and not really significant in terms of performance..

It's possible that the 2nd insert is throwing an exception, perhaps because of a constraint violation, so look at your exception logs, if you haven't.

It's also possible that your driver/database is simply broken and doesn't support this correctly.
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic