aspose file tools*
The moose likes JDBC and the fly likes copy talble using jdbc Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "copy talble using jdbc" Watch "copy talble using jdbc" New topic
Author

copy talble using jdbc

ZhiningZhang
Greenhorn

Joined: Jun 13, 2001
Posts: 18
Hello, all,
I have two two dababases. How to copy a table in one database to another database???
Thanks!
-Zhining
Simon Xu
Ranch Hand

Joined: Aug 16, 2000
Posts: 235
Just take out the data from the first table and store them into some variables and then insert them into second table.
regards
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
Well, using JDBC you could always query from one and insert the results into the other.
ZhiningZhang
Greenhorn

Joined: Jun 13, 2001
Posts: 18
Thanks,Xu and Menard.
But my problem is I do not know the source table's schema ( how many columns, column's type ), only know table's name. I know I can use metadata in jdbc to get table's schema, then create a new table, and copy all data.
Is there a easy way to do it?
Thanks! -Zhining
vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
You can download/copy one database to the other with ease if you are using SQL or ORACLE.They have the option of import/export database in management console.It will just ask for the location of the table,username password if any and start downloading.
Isn't it easy?You can even download the database of two different vendors.


VAIBHAV <BR>SCJP
vaibhav punekar
Ranch Hand

Joined: Jan 20, 2001
Posts: 134
No need of JDBC also.
ZhiningZhang
Greenhorn

Joined: Jun 13, 2001
Posts: 18
My project is to write a utility using jdbc to convert database. The source database could be MS SQL Server on one server, while target database could be ORACLE on another server. I do not the schema of table ( different users could have different schema ), only know the table name.
I am wondering if there is a easy way to copy tables.
-Zhining
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: copy talble using jdbc