Java implements Oracle Database Backup
Today, we will paste an Oracle database backup feature that has been implemented very early. This feature was designed at the university stage:
Import java. io. File;
Import java. io. IOException;
/**
* Oracle Database Backup
*
* @ Author GaoHuanjie
*/
Public class OracleDatabaseBackup {
/**
* Java code for Oracle Database Export
*
* @ Author GaoHuanjie
* @ Param userName the userName required to enter the database
* @ Param password the password required to enter the database
* @ Param SID the SID of the user
* @ Param savePath: path for saving the exported database file
* @ Param fileName: name of the exported file in the database
* @ Return true indicates that the export is successful; otherwise, false is returned.
*/
Public static boolean exportDatabaseTool (String userName, String password, String SID, String savePath, String fileName) throws InterruptedException {
File saveFile = new File (savePath );
If (! SaveFile. exists () {// If the directory does not exist
SaveFile. mkdirs (); // create a folder
}
Try {
Process process = runtime.getruntime(cmd.exe c ("exp" + userName + "/" + password + "@" + SID + "file =" + savePath + "/" + fileName + ". dmp ");
If (process. waitFor () = 0) {// 0 indicates that the thread is terminated normally.
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 ("the database is successfully backed up !!! ");
} Else {
System. out. println ("database backup failed !!! ");
}
}
}
Oracle 11g installation manual on RedHat Linux 5.8 _ x64 Platform
Installing Oracle 12C in Linux-6-64
Install Oracle 11gR2 (x64) in CentOS 6.4)
Steps for installing Oracle 11gR2 in vmwarevm
Install Oracle 11g XE R2 In Debian