i want to take my sql db backup using java code. i am using this code this code ids giving following exception
我想使用java代码获取我的sql db备份。我正在使用此代码此代码ID给出以下异常
Thanks
java.io.IOException: Cannot run program "mysqldump": CreateProcess error=2, The system cannot find the file specified
class DbBackup {
public static void main(String[] args) {
Process p = null;
try {
Runtime runtime = Runtime.getRuntime();
p = runtime.exec("E:/xampp/mysql/bin/mysqldump -uroot -p'' --add-drop-database -B HighCourt -r " + "G:/JAVAWORK" + "1" + ".sql");
int processComplete = p.waitFor();
if (processComplete == 0) {
System.out.println("Backup created successfully!");
} else {
// lblMessage.setText("Could not create the backup");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
1 个解决方案
#1
0
The runtime does not know where to look for mysqldump.
运行时不知道在哪里查找mysqldump。
Provide a full path to it. /usr/bin/mysqldump
or something. Depends on the OS.
提供完整的路径。 / usr / bin / mysqldump等等。取决于操作系统。
#1
0
The runtime does not know where to look for mysqldump.
运行时不知道在哪里查找mysqldump。
Provide a full path to it. /usr/bin/mysqldump
or something. Depends on the OS.
提供完整的路径。 / usr / bin / mysqldump等等。取决于操作系统。