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:

[Java]View PlainCopy
  1. Import Java.io.File;
  2. Import java.io.IOException;
  3. /**
  4. * Oracle Database Backup
  5. *
  6. * @author Gaohuanjie
  7. */
  8. Public class Oracledatabasebackup {
  9. /** 
  10. * Java code for Oracle database export
  11. *
  12. * @author Gaohuanjie
  13. * @param userName User name required to enter the database
  14. * @param password The password required to enter the database
  15. * SID of @param SID user
  16. * @param savepath Database Export File save path
  17. * @param filename Export file name of the filename database
  18. * @return returns True to indicate that the export was successful, otherwise false.
  19. */
  20. public Static boolean Exportdatabasetool (String userName, string password, string SID, String Savepath, Strin G FileName) throws interruptedexception {
  21. File SaveFile = new File (Savepath);
  22. if (!savefile.exists ()) {//If the directory does not exist
  23. Savefile.mkdirs (); //Create a folder
  24. }
  25. try {
  26. Process process = Runtime.getruntime (). EXEC ("exp" + userName + "/" + password + " @" + SID + "file=" + SA  Vepath + "/" + FileName + ". DMP");
  27. if (process.waitfor () = = 0) {//0 indicates normal termination of the thread.
  28. return true;
  29. }
  30. } catch (IOException e) {
  31. E.printstacktrace ();
  32. }
  33. return false;
  34. }
  35. public static void Main (string[] args) throws interruptedexception {
  36. if (Exportdatabasetool ("Gaohuanjie", "ab19890110", "ORCL", "D:/backupdatabase" , "oracledb ")) {  
  37. SYSTEM.OUT.PRINTLN ("database successfully backed up!!!  ");
  38. } Else {
  39. SYSTEM.OUT.PRINTLN ("Database backup failed!!!  ");
  40. }
  41. }
  42. }

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.