File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes How can I Insert vector elements into a DB?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "How can I Insert vector elements into a DB??" Watch "How can I Insert vector elements into a DB??" New topic

How can I Insert vector elements into a DB??

john Phillips

Joined: Oct 14, 2004
Posts: 2
Hello all you java Geniuses.
I have been trying to do the following task for some time now
can anybody pls help me on how to go about it ,Here is the task
I want to insert all the selected records from tableA into tableB
both tables are in the same database and have the same table structure.
They both have about 6 columns each.I'm using a vector to store all the
results returned by table A ,then use a for loop to loop trough the vector
and at the same time convert the Vector to a String variable so that I can Insert them into TableB but I have a problem identifing each of the elements so as to know which one will be currently inserted into the right column out of the six columns on Table B.
[ October 14, 2004: Message edited by: john Phillips ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

Hmm. Why do this when this line of SQL:

will do it for you?

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

I think the SQL technique is the best, but if for some reason you can't do this, then just don't process the information so much. Take the results directly from the ResultSet, and feed them to a PreparedStatement; this way you can let Java do most of the detail work for you.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: How can I Insert vector elements into a DB??
It's not a secret anymore!