This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC 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 ...
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

I need some help  RSS feed

 
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone
I know i have posted about this topic before, But i am realy Stuck.
Could someone please be so kind as to help me?
I have a preparedStatement, and I have a arraylist with 30 words inside it, now i want to get the first 10 words from the arraylist and put them into the first column name i have, Then i want to get the next 10 words from the arraylist(10 to 20), and put them into the second column name that i have. and so on with the third. And they need to be in diffrent rows.
as you can see that the first column name needs to get the words 0 to 10 from the arraylist, the second column name needs to get the words 10 to 20 from the arraylist, and the last column name needs to get the words 20 to 30 from the arraylist.
I need to do this by using one preparedStatment.
So if anyone is so kind to help me I would be most gratefull as i am realy stuck with this.
thanks
ben
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben,
You can't do that with one List, at least not any way that I know of. Each bind variable in a PreparedStatement is set once and only once for each execute.
My advice would be to parse all this first names into an ArrayList, then all the middle names into a second ArrayList, and so on. Then create a loop that loops through all of the lists at once, i.e.

I mentioned this before, but I'll say it again, be sure to read the javadoc for PreparedStatement, that should always be your first option if you have questions about a specific class or interface.
E
[ January 20, 2003: Message edited by: Eric Fletcher ]
[ January 20, 2003: Message edited by: Eric Fletcher ]
 
He puts the "turd" in "saturday". Speaking of which, have you smelled this tiny ad?
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!