private void jMenuItem16ActionPerformed(java.awt.event.ActionEvent evt)
{
int r = JOptionPane.showConfirmDialog(null, "Backup ??" , "Backup" , JOptionPane.YES_NO_OPTION);
if(r==0){
String filename = BackupNamer.getname();
try{
Process rt = Runtime.getRuntime().exec("cmd.exe /C path=C:\\Program Files\\MySQL\\MySQL Server 5.6\\bin;mysqldump -uroot --password=12345 librarysystem>D:\\"+filename+"");
int pr = rt.waitFor();
if(pr==0){
JOptionPane.showMessageDialog(null, "backup created");
}
else if(pr==1){
JOptionPane.showMessageDialog(null, "error");
}
}catch(Exception e){
System.out.println(e);
}
}
}
通过这段代码,我想创建我的数据库的备份。但它只在给定路径中创建一个空文件。