Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating multiple rows

 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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.




Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are running you insert statement in a loop.
 
Leonardo Carreira
Ranch Hand
Posts: 489
Eclipse IDE Java Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir..

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

Thanks in advance...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34084
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
pankaj semwal
Ranch Hand
Posts: 303
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then how to solve this problem.

Please tell me.

Thanks
 
Vijitha Kumara
Bartender
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham said correct answer.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic