The moose likes JDBC and Relational Databases and the fly likes I need some help 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 "I need some help" Watch "I need some help" New topic

I need some help

ben riches
Ranch Hand

Joined: Nov 08, 2002
Posts: 126
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.
Eric Fletcher
Ranch Hand

Joined: Oct 26, 2000
Posts: 188
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.
[ January 20, 2003: Message edited by: Eric Fletcher ]
[ January 20, 2003: Message edited by: Eric Fletcher ]

My theory of evolution is that Darwin was adopted. - Steven Wright
I agree. Here's the link:
subject: I need some help
It's not a secret anymore!