在JAVA里调用数据库备份命令——怎么获得返回值?

2dian1G 2003-08-21 10:41:08
Runtime rt = Runtime.getRuntime();
int rc = -1;

try
{
cmd ="exp 用户名/口令@连接串 owner=表的所有者 buffer=10240 file=d:\database.dmp log=d:\database.log";
Process proc = rt.exec(cmd);
int bufSize = 10240;
BufferedInputStream bis =
new BufferedInputStream(proc.getInputStream(), bufSize);
int len;
byte buffer[] = new byte[bufSize];

// Echo back what the program spit out
while ((len = bis.read(buffer, 0, bufSize)) != -1)
System.out.write(buffer, 0, len);

rc = proc.waitFor();
}
catch (Exception e)
{
e.printStackTrace();
rc = -1;
return false;
}
finally
{
System.out.write(rc);
return true;
}
如果我的命令当中包含的数据库口令是错误的,不能象我直接在CMD窗口中可以得到的提示进行重新输入,这个进程好象始终是处于等待状态,我该怎么解决?多谢指点。
...全文
52 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
qwater 2003-09-15
  • 打赏
  • 举报
回复
up
lilylamb 2003-08-25
  • 打赏
  • 举报
回复
我刚接触java觉得她对进程管理、内存不是很好,即使关闭也不是很理想
klbt 2003-08-23
  • 打赏
  • 举报
回复
顶!
2dian1G 2003-08-23
  • 打赏
  • 举报
回复
up

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧