Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on insert records into table using java

 
Melinda Savoy
Ranch Hand
Posts: 387
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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 ]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
sandeep TA
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic