1、exp导出数据库表格数据 : cmd.exe /c exp user/password@TEST_LOCAL file=D:\test\test.dmp tables=(tablename1,tablename2,tablename3)
2、java调用cmd命令 : Process process = Runtime.getRuntime().exec(commandStr);
要注意读取ErrorStream和InputStream;以免进程挂起;
process.waitFor(); 等待进程执行完成;
2、java调用cmd命令 : Process process = Runtime.getRuntime().exec(commandStr);
要注意读取ErrorStream和InputStream;以免进程挂起;
process.waitFor(); 等待进程执行完成;
代码如下:
public boolean backupData()
{
boolean isSuccess = false;
String dataSource = "TEST_LOCAL";
String backupLocation = "D:\\test\\";
Date date = new Date();
DateFormat df = DateFormat.getDateTimeInstance();// 精确到时分秒
String dmpName = "test_" + df.format(date) + ".dmp";
dmpName = dmpName.replace(" ", "_");
dmpName = dmpName.rep