【发布时间】:2019-05-25 16:03:33
【问题描述】:
我在一个数据库表中有记录,我想将所有记录转移到另一个数据库的表中。
我目前的代码只能在同一个数据库的表之间传输。
Statement st = conn.createStatement();
int rows = st.executeUpdate("Insert into script(ID,Name) Select ID,Name from table1");
if(rows==0){
JOptionPane.showMessageDialog(null,"Nothing to transfer.");
}else{
JOptionPane.showMessageDialog(null,rows+" transfered successfully into script");
}
}catch(SQLException | HeadlessException e){
JOptionPane.showMessageDialog(null,e);
}finally{
try{
rs.close();
pst.close();
}
catch(Exception e){
}
}
//and below are my database connections.
public into_databses(){
conn = connector.db1();
conn1 = connector.db2();
}
//and I am currently using only conn=connector.db1```
I want to modify it so that I can transfer records between tables in the different databases. thank you
【问题讨论】:
-
您使用的是哪个数据库?
-
sqlite3 @scaisEdge