public class SubjectImpornt {
public static final String url = "jdbc:mysql://IP地址/数据库名称";
public static final String name = "com.mysql.jdbc.Driver";
public static final String user = "root";
public static final String password = "ln123";
public static final String urlo = "jdbc:oracle:thin:@IP地址:端口号:orcl";
public static final String nameo = "oracle.jdbc.driver.OracleDriver";
public static final String usero = "账号";
public static final String passwordo = "密码";
public static Connection conn = null;
public static PreparedStatement pst = null;
public static Connection conno = null;
public static PreparedStatement psto = null;
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String select_sql = "select * from b2_subnumber_mgr";
String insert_sql = "insert into SUBJECT (ID, SUBJECT_NAME, SUBJECT_NUM) values (?,?,?)";
Class.forName(name);
Class.forName(nameo);
conn = DriverManager.getConnection(url, user, password);
conno = DriverManager.getConnection(urlo, usero, passwordo);
pst = conn.prepareStatement(select_sql);
psto = conno.prepareStatement(insert_sql);
ResultSet rs = pst.executeQuery();
while(rs.next()) {
psto.setString(1, IdUtil.getUUID());
psto.setString(2, rs.getString(4));
psto.setString(3, rs.getString(5));
psto.executeUpdate();
}
rs.close();
pst.close();
psto.close();
conn.close();
conno.close();
}
public static final String url = "jdbc:mysql://IP地址/数据库名称";
public static final String name = "com.mysql.jdbc.Driver";
public static final String user = "root";
public static final String password = "ln123";
public static final String urlo = "jdbc:oracle:thin:@IP地址:端口号:orcl";
public static final String nameo = "oracle.jdbc.driver.OracleDriver";
public static final String usero = "账号";
public static final String passwordo = "密码";
public static Connection conn = null;
public static PreparedStatement pst = null;
public static Connection conno = null;
public static PreparedStatement psto = null;
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String select_sql = "select * from b2_subnumber_mgr";
String insert_sql = "insert into SUBJECT (ID, SUBJECT_NAME, SUBJECT_NUM) values (?,?,?)";
Class.forName(name);
Class.forName(nameo);
conn = DriverManager.getConnection(url, user, password);
conno = DriverManager.getConnection(urlo, usero, passwordo);
pst = conn.prepareStatement(select_sql);
psto = conno.prepareStatement(insert_sql);
ResultSet rs = pst.executeQuery();
while(rs.next()) {
psto.setString(1, IdUtil.getUUID());
psto.setString(2, rs.getString(4));
psto.setString(3, rs.getString(5));
psto.executeUpdate();
}
rs.close();
pst.close();
psto.close();
conn.close();
conno.close();
}
}