Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Question on insert records into table using java

 
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to insert records from one sql table into another table automatically by running this method for JUNIT testing purposes. Here is the code that I've tried to write but I'm stuck as to get it to work as well as wondering if I'm going about correctly, so ANY HELP or DIRECTION would be appreciated:



[edited to add code tags]
[ September 23, 2005: Message edited by: Jeanne Boyarsky ]
 
author & internet detective
Posts: 40913
840
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Melinda,
What error message are you getting when it doesn't work?

For the approach, I'm not sure I understand what you are trying to accomplish or what you are trying to test. For example, where are you copying data from/to. A backup database? For later comparison?

In JUnit, you typically don't have printlns [assertions are used instead], but that might just be for the sake of example.
 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much for the reply.

I'm fairly new to Java and I was trying to select from one table and insert the results into a another table. I think I now know that I need to return a resultset and then use that resultset in another method to use in an insert statement by passing into that method the resultset.

Thank you for your time and response.

Regards.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Insert you have to specify like the following

insert into tablename values('"+column+"','"+column2+"',.....);


Then only it inserts into table
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic