Win a copy of Spring Boot in Practice this week in the Spring 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How can I Insert vector elements into a DB??

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm. Why do this when this line of SQL:

will do it for you?
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic