Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I need some help

 
ben riches
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
 
Eric Fletcher
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic