Java for Oracle database backup

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.