我有两个不同的数据库(SqlServer,Oracle)
SqlServer有 CUSTOMER_ID 信息, Oracle有 CUSTOMER_ID 等列信息
我想达到以下场景(从第一种方法获取记录集并将该值作为条件应用到(WHERE IN)第二种方法中)
public void getvariable_values() throws SQLException, ClassNotFoundException
{
System.out.println("Oracle Start Connecting Server");
oracon = DriverManager.getConnection(oe_url, oe_user, oe_password);
System.out.println("Oracle Connection succeed");
Statement s1 = (Statement) oracon.createStatement();
sql_rs_var = s1.executeQuery("SELECT CUSTOMER_ID FROM CUSTOMER_SERVER )");
getDatafromsql(sql_rs_var);
}
public void getDatafromsql(Resultset inp_record) throws SQLException, ClassNotFoundException
{
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
System.out.println("SQL Server Start Connecting ");
Connection sqlcon = DriverManager
.getConnection(s_url, s_username, s_password);
System.out.println("Sql server Connection valid");
PreparedStatement s1 = sqlcon.prepareStatement("SELECT TOP 6 * FROM documents where customer_id = ?");
//Something want to apply like below for where in condition
s1.setString( 1,inp_record);
sql_rs = s1.executeQuery();
setdataOracle(sql_rs);
sqlcon.close();
}
请建议如何在 SQL 中的方法 (getDatafromsql) 中应用 WHERE IN 条件中的完整记录集