如何使用Java创建多个模式连接? [英] How to create multiple schema connections using Java?
问题描述
我必须使用两个数据库:
I have to work with two database:
- DB2
- Oracle
我在DB2数据库中有一个名为 NAVID
的架构。我想使用Java与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;
}
我不知道如何使用列选择所有表,并创建相同的表db2。
I dont know how to select all tables with columns and create the same tables in db2.
推荐答案
为了做这样的事情,我邀请你做出多种方法;第一种方法必须选择一个表并获取这些值并将其复制到一个向量中,而第二种方法则需要一个参数;该向量并采用这些值并将其插入到第二个数据库oracle中。
如果您想要任何其他信息,请在我的Gmail帐户zahranemehdi@gmail.com与我联系。
To make such thing i invite you to make multiple methods; the first method must select a table and get those values and copy them into a vector, and the second method take an argument; the vector and take those values and insert them in the second database 'oracle'. If you would like any other informations contact me in my gmail account zahranemehdi@gmail.com.
这篇关于如何使用Java创建多个模式连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!