I have to work with two database:
- DB2
- Oracle
I have a schema in DB2 database named NAVID
. I want to create the same schema with all tables in Oracle using Java.
public class automateExport {
static String value;
public static void main(String[] args) throws SQLException, ClassNotFoundException {
ResultSet rs = null;
Connection DB2 = getConnection();
String sqlstm = "SELECT * FROM SYSCAT.COLUMNS WHERE TABSCHEMA NOT LIKE 'SYS%'";
PreparedStatement mainStmt = DB2.prepareStatement(sqlstm);
ResultSet query = mainStmt.executeQuery();
}
private static Connection getConnection() throws ClassNotFoundException, SQLException{
Class.forName("com.ibm.db2os390.sqlj.jdbc.DB2SQLJDriver");
Connection connection =
DriverManager.getConnection("jdbc:db2://localhost:50000/navid","navid","oracle");
return connection;
}
I dont know how to select all tables with columns and create the same tables in db2.