Java code to import backup database files to the Oracle database

Source: Internet
Author: User

Java code to import backup database files to the Oracle database

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. IOException;/*** Java code to import the backed up database file to the Oracle database ** @ author: gaohuanjie */public class OracleImportDatabase {/*** import the backed up database file to the Oracle database ** @ author: gaohuanjie * @ param userName the userName required to enter the database * @ param password the password required to enter the database * @ param SID the user's SID * @ param fromUserName the original user of the data file imported * @ param filePath: Path of the database backup file without the extension * @ return returns true, indicating that the import is successful, if false is returned, the Import fails */public static boolean importDatab. Ase (String userName, String password, String SID, String fromUserName, String filePath) throws InterruptedException {String toUserName = userName; try {Process process = runtime.getruntime(cmd.exe c ("imp" + userName + "/" + password + "@" + SID + "fromuser =" + fromUserName + "touser =" + toUserName + "file =" + filePath + ". 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 (importDatabase ("gaohuanjie", "ab19890110", "orcl ", "gaohuanjie", "D: \ oracledb") {System. out. println ("the database has been imported successfully !!! ");} 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.