JAVA实现数据库备份与还原(5)
时间:2026-01-23
时间:2026-01-23
数据库的备份import java.io.IOException;
import javax.swing.JOptionPane;
public class JavaOutputOracle {
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
Process processexp = null;// 创建一个本机进程
String exp = "exp scott/tiger@oracle file=d:/gengen.dmp";
try {
processexp = rt.exec(exp);
if (processexp.waitFor() != 0) {
JOptionPane.showMessageDialog(null, "数据库备份失败");
} else {
JOptionPane.showMessageDialog(null, "数据库备份成功");
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
数据的恢复:
import java.io.IOException;
import javax.swing.JOptionPane;
public class OracleInput{
public static void main(String[] args) {
Runtime rt = Runtime.getRuntime();
Process processexp = null;
String imp = "imp scott/tiger@oracle file=d:/gengen.dmp";