Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems when using oracle8 imp command with runtime.exec()

 
Joy zhang
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some problems when I invoke oracle imp in Runtime.getRuntime().exec().I run my program under win2000 server and Oracle8.Here is my code snip:
boolean restore()
{
Process proc = Runtime.getRuntime().exec("imp user/pwd fromuser=user1 touser=user2 file=d:/dbup.dmp log=d:/dblog.log");
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream());
String line = null;
while((line = br.readLine())!=null)
{
//do nothing
}
int result = proc.waitFor();
if(result == 0)
{
return true;
}
return false;
}
when I invoke method 'restore',it never returns.I tried to replace proc.getInputStream() with proc.getErrorStream(),the problem still exists.When I run the command in dos window,it exists successfully.
So,is there anything i forgot?
Besides,what is the difference between proc.getInputStream() and proc.getErrorStream(),when to use one instead the other?
Thanks!
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In theory what you are doing looks right.
Did you try replacing your exec call with something simple like "notepad.exe"? That way you can make sure that all the rest of the code works.
I used

This works.
But of course when I used your exec() call I get a null pointer exception.
[ August 20, 2003: Message edited by: Cindy Glass ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic