原理:生产任务计划,调用批处理文件
package edu.fafu.utils;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Date;
public class DataBaseUtil {
/*
* 数据库备份bat
*/
public static void backUpDataBaseOracle(String userName, String pwd,
int loginId, int index) throws IOException {
StringBuffer sbBackup = new StringBuffer("@echo off\r\n");
sbBackup
.append("set var_date=%date:~0,4%-%date:~5,2%-%date:~8,2%_%time:~0,2%_%time:~3,2%_%time:~6,2%");
sbBackup.append("\r\n");
sbBackup.append("exp ");
sbBackup.append(userName);
sbBackup.append("/");
sbBackup.append(pwd);
sbBackup.append("@192.168.0.174:1521/orcl");
sbBackup.append(" file=C:\\%var_date%.dmp owner");
sbBackup.append("(");
sbBackup.append(userName);
sbBackup.append(")");
sbBackup.append("\r\n");
sbBackup.append("set fileurl='C:\\%var_date%.dmp'");
sbBackup.append("\r\n");
sbBackup.append("echo insert into databackup ");
sbBackup.append("(");
sbBackup.append("fileurl,loginid");
sbBackup.appen