The Oracle database backup feature, which was implemented early today, was written at the University stage design:
[Java]View PlainCopy
- 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 User name required to enter the database
- * @param password The password required to enter the database
- * SID of @param SID user
- * @param savepath Database Export File save path
- * @param filename Export file name of the filename database
- * @return returns True to indicate that the export was successful, otherwise false.
- */
- public Static boolean Exportdatabasetool (String userName, string password, string SID, String Savepath, Strin G 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 (). EXEC ("exp" + userName + "/" + password + " @" + SID + "file=" + SA Vepath + "/" + FileName + ". DMP");
- if (process.waitfor () = = 0) {//0 indicates normal termination of the thread.
- 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 ("database successfully backed up!!! ");
- } Else {
- SYSTEM.OUT.PRINTLN ("Database backup failed!!! ");
- }
- }
- }
Java for Oracle database backup