Java implements Oracle Database Backup

Source: Internet
Author: User

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 required username * @ param password the password required to enter the database * @ param SID the SID of the user * @ param savePath Database Export File Storage path * @ param fileName Database Export File name *@ 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 backed up successfully !!! ");} 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.