You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

1 year ago
package com.zky.util;
public class Test {
public static void backup(String dbName, String filePath) {
try {
@SuppressWarnings("unused")
Process process = Runtime.getRuntime().exec(
"cmd /c mysqldump -uroot -proot " + dbName + " > "
+ filePath + "/" + new java.util.Date().getTime()
+ ".sql");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@SuppressWarnings("unused")
1 year ago
// <20>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ݿ<EFBFBD>
1 year ago
public static void load(String dbName, String filePath) {
try {
@SuppressWarnings("unused")
Process process = Runtime.getRuntime().exec(
"cmd /c mysql -uroot -psa " + dbName + " < " + filePath);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
backup("orcl","d:/");
//oad("test", "d:/1259138711453.sql");
System.out.println("ok");
} catch (Exception e) {
// TODO: handle exception
e.getMessage();
}
}
}