wood burning stoves 2.0*
The moose likes Java in General and the fly likes problems when using oracle8 imp command with runtime.exec() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "problems when using oracle8 imp command with runtime.exec()" Watch "problems when using oracle8 imp command with runtime.exec()" New topic
Author

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

Joy zhang
Greenhorn

Joined: Jan 03, 2002
Posts: 7
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

Joined: Sep 29, 2000
Posts: 8521
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 ]

"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems when using oracle8 imp command with runtime.exec()