Could someone give me pointers on how to transfer data between two tables that are identical in structure, but located in different databases. This task needs to be accomplished through code.
A single program can certainly have multiple databases open. Each java.sql.Connection object is tied to a single database, but you can have several Connection objects, each pointing to a different database, and switch back and forth between them in your program as you need to.
If it's a lot of data, you could run the export/import system procedures. Export the data from the source table to a text file, then import it to the target table. If it's a small amount of data, you can open two connections in your program, read the data from the source table, and insert the data into the target table. Depending on how generic your transfer code needs to be, you could simply hard-code the names of columns and their data types in your code. Or, you could use the DatabaseMetaData classes to determine the column names at runtime and write a generic transfer routine. Why don't you post the code you've tried so far, and the problems you've encountered, and the community can then suggest solutions to those problems. thanks, bryan
