Java code implementation imports backed up database files to an Oracle database

Source: Internet
Author: User

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

Import java.io.ioexception;/** * Java code Implementation imports backed up database files into an Oracle database * * @author: Gaohuanjie */public class oracleimportdatabase {/** * Import the backed up database files into the Oracle database * * @author: Gaohuanjie * @param userName the username required to enter the database * @param passwor d The password required to enter the database * @param SID user's SID * @param fromusername imported data files The original user * @param filePath does not contain the extension of the database backup file path * @return return True Indicates that the import succeeded and returned false to indicate that the import failed */public static Boolean importdatabase (string userName, string password, string SID, String Fromuser Name, String filePath) throws Interruptedexception {string tousername = username;try {Process Process = Runtime.getruntime  (). EXEC ("imp" + userName + "/" + password + "@" + sid+ "fromuser=" + fromusername + "touser=" + tousername + "file=" + FilePath + ". 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 (Importdatabase ("Gaohuanjie", "ab19890110", "ORCL "," Gaohuanjie "," D:\\oracledb ")) {System.out.println ("Database successfully imported!!! ");} else {System.out.println ("Database import 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.