The Oracle database backup feature, which was implemented very early today, was written at the university stage design time:
Import java.io.file;import java.io.ioexception;/** * Oracle Database Backup * * @author Gaohuanjie */public class Oracledatabaseback Up {/** * Java code for Oracle database export * * @author Gaohuanjie * @param userName required to enter the database userName * @param password password required to access the database * @param SID User's SID * @param savepath Database Export File save path * @param filename Database Export file name * @return Returns True to indicate that the export was successful, otherwise it returns false. */public Static Boolean Exportdatabasetool (string userName, string password, string SID, String Savepath, String fileName) Throws Interruptedexception {file SaveFile = new File (Savepath), if (!savefile.exists ()) {//Assuming the folder does not exist Savefile.mkdirs (); /Create folder}try {process process = Runtime.getruntime (). EXEC ("exp" + userName + "/" + password + "@" + SID + "file=" + SAVEP Ath + "/" + 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