您好,我无法还原backup.sql文件,该文件是由mysqldump命令run through java runtime.exec()方法通过我的java应用程序在runtime.exec()中使用字符串数组命令创建的。
我读了很多类似的帖子……但还是没能解决这个问题。
代码段如下:
String dbname ="db2";
String dbuser = "root";
String dbpassword = "1243";
String sourcepath = JTextField2.getText();
boolean status=false;
String[] command = new String []{"mysql","-u "+dbuser+" -p",dbpassword,dbname,"-e","source "+sourcepath};
try{
Process runtimeprocess=Runtime.getRuntime().exec(command);
int processComplete=runtimeprocess.waitFor();
if(processComplete==0){
status=true;
JOptionPane.showMessageDialog(null,"Restored successfully!!");
}else{
JOptionPane.showMessageDialog(null,"Restore failed!!");
}
}catch(IOException ioe){
JOptionPane.showMessageDialog(null, ioe);
}catch(Exception e){
JOptionPane.showMessageDialog(null, e);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!