此代码确实恢复了 mysql 表,但应用程序几乎进入睡眠状态(超过 20 分钟)。而且我的数据库例程没有出现在 mysql 工作台中,有人可以告诉我实际的解决方案是什么吗?
public static boolean restoreDB(String dbName, String dbUserName, String dbPassword, String source) {
String[] executeCmd = new String[]{"C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin\\mysql", "--user=" + dbUserName, "--password=" + dbPassword, "-e", "source \"D:/khokher/mydb.sql\""};
Process runtimeProcess;
try {
runtimeProcess = Runtime.getRuntime().exec(executeCmd);
int processComplete = runtimeProcess.waitFor();
if (processComplete == 0) {
System.out.println("Backup restored successfully");
return true;
} else {
System.out.println("Could not restore the backup");
}
} catch (Exception ex) {
ex.printStackTrace();
}
return false;
}