备份:
try {
Runtime.getRuntime().exec(new String[] { "sh", "-c"," mysqldump -u use -ppassword qofdb table1>/home/table1.sql"});
} catch (IOException ex) {
Logger.getLogger(JFrame1.class.getName()).log(Level.SEVERE, null, ex);
}
还原:
try {
Runtime.getRuntime().exec(new String[] { "sh", "-c"," mysql -u use -ppassword qofdb</home/table1.sql"});
} catch (IOException ex) {
Logger.getLogger(JFrame1.class.getName()).log(Level.SEVERE, null, ex);
}
这个exec的执行方式还有点费解,sh和-c为啥要分开写,有空再看看。虽然select out into 的效率更高一点。可惜存储位置有限制,而且不能覆盖。虽然有pager的方式来绕开。算了就这样把。