File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Merging a data from one table into other. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Merging a data from one table into other." Watch "Merging a data from one table into other." New topic
Author

Merging a data from one table into other.

Ram singh
Greenhorn

Joined: Jul 10, 2003
Posts: 6
Hello,
I have two table that have exactly the same fields. So, i created a new table and want to merge both of the tables rows into this new table. I have a wrapper classes for both tables and currently want to just merge one of those 2 tables in the new one. This is wut i wrote:

String sessionid = "";
PrivateSession ps = new PrivateSession(sessionid); //wrapper class for the old table
THis is the query that i wrote:
query = " INSERT INTO Tempsession VALUES(" + ps.sessionid +",\"" + ps.performerid + "\",'PRIVATE', \"" + ps.passcode + "\", \"" + ps.featid + "\",\"" + ps.refid + "\"," + starttime +", " + endtime +","+ ps.duration +", "+ ps.endreason +", " + ps.rate +", " + ps.pays +")";
// PRIVATE IS teh value for all the rows for that particluar column.
it compiles and runs with Java command. but when i do a query on Tempsession, it returns empty???...Anyone have any idea why its doing that...Any help would be greatly appreciated. THanks a lot.
Gayathri Prasad
Ranch Hand

Joined: Jun 25, 2003
Posts: 116
Hi Ram,
There might be 2 possibilties.
1) You are not handling the run-time exceptions
2) There might not be any data from the session which you are using wrapper class (PrivateSession).
Cheers,
Gaya3
Ram singh
Greenhorn

Joined: Jul 10, 2003
Posts: 6
Hey,
I can post both the classes here or can email them. I really need help with this. I'll really aprreciate it. THanks..
Ram singh
Greenhorn

Joined: Jul 10, 2003
Posts: 6
Or, is there a way i can directly insert the values from the old table into the new one without having to use the wrapper class for the old table..THanks..
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1817

You should be able just to issues a SQL statement to acheive this. Try somethign along the lines of:


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Ram singh
Greenhorn

Joined: Jul 10, 2003
Posts: 6
I have one more field in the new table that doesn't exist in the old one..so, how would i put that in as well..adn plus, i tried to run ur query and its giving me a nullPointerException during run....
 
wood burning stoves
 
subject: Merging a data from one table into other.
 
Similar Threads
comparing 2 resultsets
Table merge
SQL Query for two tables joining
How to map one class to multiple similar tables with Hibernate?
SQL Query for two tables joining