jsp javabean备份还原
import java.lang.Runtime;
import java.io.*;
public class Mysql
{
Mysql()
{
}
public void Put() throws IOException{
String command = "mysqldump -h 127.0.0.1 -u root --opt test > c:/test.txt"; //test是表名 这里没有用密码所以没有-p可在root后加 -p 密码
Runtime.getRuntime().exec("cmd /c "+command);
System.out.println("备份成功");
}
public void In() throws IOException{
Runtime.getRuntime().exec("cmd /c mysql -h 127.0.0.1 -u root test<c:/test.txt");
System.out.println("还原成功");
}
public static void main(String [] ages)
{
Mysql my=new Mysql();
try{
my.In();
}
catch(Exception y)
{
y.toString();
}
}
}