我有从 2 个数据库调用查询的代码,但它必须同时编译。这是我的代码
public void SummTEkspor(){
TEkspor ti = new TEkspor();
TEksporDAOImpl impd = new TEksporDAOImpl (DBConnection.getInstance().getCon());
String sql1 ="DELETE FROM a.dbo.t_export\n" +
"INSERT INTO a.dbo.t_export\n" +
"SELECT * FROM b.dbo.export x WHERE x.sk_batch IN \n" +
"(SELECT sk_batch from batch_hdr WHERE
mth="+cmbBln.getSelectedItem()+
"AND year="+cmbThn.getSelectedItem();
try {
Statement st = kon.conn.createStatement();
Statement st2 = kon.secCon.createStatement();
ResultSet rs = st.executeQuery(sql1);
while (rs.next()) {
System.out.println("success");
}
} catch (Exception x) {
System.out.println("error");
}
}
但是,当我运行它时,输出很好,但是查询没有正确执行,我的表中没有数据,而该表上有一些数据。
有没有办法解决这个问题?感谢您的任何回复