今天将很早就实现的一个Oracle数据库备份功能粘贴出来,这个功能是在大学做阶段设计时写的:
- import java.io.File;
- import java.io.IOException;
-
- public class OracleDatabaseBackup {
-
-
- public static boolean exportDatabaseTool(String userName, String password, String SID, String savePath, String fileName) throws InterruptedException {
- File saveFile = new File(savePath);
- if (!saveFile.exists()) {
- saveFile.mkdirs();
- }
- try {
- Process process = Runtime.getRuntime().exec("exp " + userName + "/" + password + "@" + SID + " file=" + savePath + "/" + fileName + ".dmp");
- if(process.waitFor() == 0){
- return true;
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return false;
- }
-
- public static void main(String[] args) throws InterruptedException {
- if (exportDatabaseTool("gaohuanjie", "ab19890110", "orcl", "d:/BackupDatabase", "oracledb")) {
- System.out.println("数据库成功备份!!!");
- } else {
- System.out.println("数据库备份失败!!!");
- }
- }
- }
Java实现Oracle数据库备份
原文:http://www.cnblogs.com/love540376/p/6255081.html