打开APP
未登录
开通VIP,畅享免费电子书等14项超值服
开通VIP
首页
好书
留言交流
下载APP
联系客服
java导入导出dmp文件
melodyjian
>《java》
2019.01.14
关注
Java代码
package com.broada.oracle.export;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class JavaOracle {
public static void main(String[] args) {
//expFile();
impFile("COSS_R2_CHENXING_NSBD_0624");
}
// 从oracle导出
public static void expFile() {
String[] cmds = new String[3];
String commandBuf = "exp COSS_R2_CHENXING_NSBD_0605/coss@220 file=c://test.dmp log=c://test.log";
cmds[0] = "cmd";
cmds[1] = "/C";
cmds[2] = commandBuf.toString();
Process process = null;
try {
process = Runtime.getRuntime().exec(cmds);
} catch (IOException e) {
e.printStackTrace();
}
boolean shouldClose = false;
try {
InputStreamReader isr = new InputStreamReader(process.getErrorStream());
BufferedReader br = new BufferedReader(isr);
String line = null;
//打印出读取的oracle导出信息
while ((line = br.readLine()) != null) {
System.out.println(line);
if (line.indexOf("????") != -1) {
shouldClose = true;
break;
}
}
} catch (IOException ioe) {
shouldClose = true;
}
if (shouldClose)
process.destroy();
int exitVal;
try {
exitVal = process.waitFor();
System.out.print(exitVal);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
// 导入oracle
public static void impFile(String user) {
String[] cmds = new String[3];
String commandBuf = "imp system/broada123@220 fromuser=COSS_R2_CHENXING_NSBD_0605 touser=" + user
+ " file=c://test.dmp 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();
}
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;
}
if (shouldClose)
process.destroy();
int exitVal;
try {
exitVal = process.waitFor();
System.out.print(exitVal);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报
。
打开APP,阅读全文并永久保存
查看更多类似文章
猜你喜欢
类似文章
【热】
打开小程序,算一算2024你的财运
java调用Oracle EXP备忘 - BlueDavy之技术Blog - BlogJa...
Java调用ffmpeg进行视频转码
java根据地址从百度API获取经纬度
Java列出 Windows 下当前运行的所有进程
如何用java启动windows命令行程序
按行读写文件
更多类似文章 >>
生活服务
热点新闻
留言交流
回顶部
联系我们
分享
收藏
点击这里,查看已保存的文章
导长图
关注
一键复制
下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!
联系客服
微信登录中...
请勿关闭此页面
先别划走!
送你5元优惠券,购买VIP限时立减!
5
元
优惠券
优惠券还有
10:00
过期
马上使用
×