File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes creating multiple rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "creating multiple rows" Watch "creating multiple rows" New topic

creating multiple rows

pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 303

Below is my code which creating multiples row.But i want only to create single row.
Can any body tell me where i am wrong .and how to solve this.

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

You are running you insert statement in a loop.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Leonardo Carreira
Ranch Hand

Joined: Apr 07, 2009
Posts: 489


is looping insert statements good for implementation?..
any suggestion?...

Thanks in advance...

Sorry, perhaps my english language isn't too good.. Prepare for SCJP 6, Please God help me.. ☼
References : [Java.Boot] [JavaChamp] [JavaPrepare]
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102

Leonardo Carreira wrote:is looping insert statements good for implementation?..
any suggestion?...

It's not the looping is bad if you want multiple rows. (Although using a batch insert would be better.)

Paul meant that your SQL inserts one row per filename. Since you expressed an interest in only having one row overall, he commented the loop would do more than that.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
pankaj semwal
Ranch Hand

Joined: Oct 07, 2008
Posts: 303
Then how to solve this problem.

Please tell me.

Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3902

pankaj semwal wrote:Then how to solve this problem.

What exactly you want to insert (in terms of number of records) apart from what Jeanne & Paul suggested? It depends on your requirement.

[How to ask questions] [Twitter]
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

So your "uploadFileNames" is an array of four strings, and you want those four strings to be the last four of the five columns you will insert into one row? Then don't use a loop:
rk palleru

Joined: Feb 26, 2009
Posts: 22
Paul Clapham said correct answer.
I agree. Here's the link:
subject: creating multiple rows
It's not a secret anymore!