aspose file tools*
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
Author

How can I Insert vector elements into a DB??

john Phillips
Greenhorn

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
Bartender

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
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

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: http://aspose.com/file-tools
 
subject: How can I Insert vector elements into a DB??