开发者

exception never thrown by Exec method in java

开发者 https://www.devze.com 2023-01-24 19:30 出处:网络
I\'m trying to execute system commands such as exp to backup a db. But if the login details are wrong or if the db does not exist then it does not throw an exception开发者_Go百科.

I'm trying to execute system commands such as exp to backup a db. But if the login details are wrong or if the db does not exist then it does not throw an exception开发者_Go百科.

How can I handle this sort of case where exceptions are thrown?

All the helpful hands are welcomed..

Regards, Swarupa


Unless you can tell something from the return code of the external process, you may be out of luck. I suppose you could maybe pipe exp's console output into a file or a stringbuffer, then parse that. Can you back it up using JDBC instead?


Java exec runs an external process. You will have to get the return value of exec() which is a Process. You should check the Process.exitValue() to see the error returned by your external process.

You can also get the inputStream from the process to see things like output of the program your are executing.


That depends a lot on what kind of database software you are using. I would check if the file for the database required exists. if((new File("dbfilename")).exists())

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号