package com.pm360.pip.sys.web;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import com.pm360.mda.platform.util.StringUtil;
/**
* @author XuFaXi
*
*/
public class ProjectExpAndImpTest {
/**
* 从数据库导出项目数据
* @param map
* @return
*/
public static String expFile(HashMap<String, Object> map) {
String info="";
String filename=StringUtil.formatDbColumn(map.get("FILENAME"));
String proj_id=StringUtil.formatDbColumn(map.get("PROJ_ID"));
String[] cmds = new String[3];
//表导出语句 如果要导出多表则在 tables参数里添加 例如 tables=(KM_DOC,KM_FOLDER,……,……)
String commandBuf = "exp pip_jk/pip@orcl file=E://"+filename+".dmp tables=(KM_DOC,KM_FOLDER) query=/"/"/" where PROJ_ID='"+proj_id+"'/"/"/"";
cmds[0] = "cmd";
cmds[1] = "/C";
cmds[2] = commandBuf.toString();
Process process = null;
try {
process = Runtime.getRuntime().exec(cmds);
} catch (IOException e) {
e.printStackTrace();
info="导入出错";
}
boolean shouldClose = false;
try {
InputStreamReader isr = new InputStreamReader(process
.getErrorStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
if (line.indexOf("????") != -1) {
shouldClose = true;
break;
}
}
} catch (IOException ioe) {
shouldClose = true;
info="导入出错";
}
if (shouldClose)
process.destroy();
int exitVal;
try {
exitVal = process.waitFor();
System.out.print(exitVal);
} catch (InterruptedException e) {
e.printStackTrace();
info="导入出错";
}
return info;
}
/**
* 导入数据库文件
* @param map
*/
public static String impFile(HashMap<String, Object> map) {
String info="";
String filepath=StringUtil.formatDbColumn(map.get("FILEPATH"));
String[] cmds = new String[3];
String commandBuf = "imp pip_jk/pip@orcl fromuser=pip_jk touser=dms file="+filepath+" ignore=y";
cmds[0] = "cmd";
cmds[1] = "/C";
cmds[2] = commandBuf.toString();
Process process = null;
try {
process = Runtime.getRuntime().exec(cmds);
} catch (IOException e) {
e.printStackTrace();
info="导入出错";
}
boolean shouldClose = false;
try {
InputStreamReader isr = new InputStreamReader(process
.getErrorStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
System.out.println(line);
if (line.indexOf("????") != -1) {
shouldClose = true;
break;
}
}
} catch (IOException ioe) {
shouldClose = true;
info="导入出错";
}
if (shouldClose)
process.destroy();
int exitVal;
try {
exitVal = process.waitFor();
System.out.print(exitVal);
} catch (InterruptedException e) {
e.printStackTrace();
info="导入出错";
}
return info;
}
}
分享到:
相关推荐
linux oracle 远程连接oracle服务器时,客服端机器需要安装imp exp命令才可以操作操作数据库导入/导出数据
oracle imp exp 命令详解 oracle imp exp 命令详解 oracle imp exp 命令详解 oracle imp exp 命令详解 oracle imp exp 命令详解
Imp和Exp命令详解 Imp和Exp命令详解 Imp和Exp命令详解Imp和Exp命令详解 Imp和Exp命令详解
Oracle数据导入导出impexp命令
imp,exp命令使用
imp-exp 命令.txt imp-exp 命令.txt
Oracle数据导入导出impexp.txtOracle数据导入导出impexp.txtOracle数据导入导出impexp.txtOracle数据导入导出impexp.txtOracle数据导入导出impexp.txtOracle数据导入导出impexp.txtOracle数据导入导出impexp....
EXP IMP命令详解
功能:Oracle数据导入导出imp/exp就相当与oracle数据还原与备份。大多情况都可以用Oracle数据导入导出完成数据的备份和还原(不会造成数据的丢失)。 Oracle有个好处,虽然你的电脑不是服务器,但是你装了oracle...
oracle命令 导入和导出命令详解 exp和imp命令详解
EXP、IMP命令详解 EXP、IMP命令详解
对oracle的exp imp命令进行了详解
先将excel文件另存为 txt 文件,用impexp32 导入到 oracle 中.zip
EXP_IMPEXP_IMPEXP_IMPEXP_IMPEXP_IMPEXP_IMPEXP_IMP EXP_IMPEXP_IMPEXP_IMPEXP_IMPEXP_IMP EXP_IMPEXP_IMPEXP_IMP
oracle exp命令、imp命令,数据库应用导入,导出
Oracle exp imp命令详解,介绍这两种命令的参数,用法
oracle11g的imp exp,oracle11g的imp exp,oracle11g的imp exp
oracle imp/exp命令,具体讲解了整库备份和还原,某几个表的备份和还原,有语法结构,有对应的实例。
EXP、IMP 命令详解
oracle数据库备份exp/imp命令详解(实例)