Java for Oracle database backup

Source: Internet
Author: User

The Oracle database backup feature, which was implemented early today, was written at the University stage design:

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 the username required to enter the database * @param password The password required to enter the database * @para Sid for M SID user * @param savepath database Export File save path * @param filename Database Export file name * @return Returns True to indicate that the export was 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 folder}try {process process = Runtime.getruntime (). EXEC ("exp" + userName + "/" + password + "@" + SID + "file=" + Savepat H + "/" + FileName + ". DMP"); if (process.waitfor () = = 0) {//0 indicates normal termination of 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!!! ");}}}

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.