File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes how do i insert more than one row to my table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how do i insert more than one row to my table" Watch "how do i insert more than one row to my table" New topic

how do i insert more than one row to my table

varsha rao

Joined: Mar 06, 2006
Posts: 26
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++)

stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
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.
It is sorta covered in the JavaRanch Style Guide.
subject: how do i insert more than one row to my table
Similar Threads
How to configure Bonecp in java project without breaking connection when more than connection
how can we use where clause with insert query using preparedStatement?
Inserting into a table
how to retrieve value from autogenerated(oracle sequence) column in a servlet.
set values in a table from other