aspose file tools*
The moose likes JDBC and the fly likes Question on insert records into table using java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Question on insert records into table using java" Watch "Question on insert records into table using java" New topic
Author

Question on insert records into table using java

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

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

Joined: May 26, 2003
Posts: 30752
    
156

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 387

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

Joined: Feb 14, 2005
Posts: 11
In Insert you have to specify like the following

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


Then only it inserts into table
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on insert records into table using java