I am trying to run an sql script(memo_222dataFERG.out here) from java and trying to capture the output from sqlplus window. Here my Code is
Runtime rt = Runtime.getRuntime();
String runString1 = "cmd /c start sqlplus pecok/pecok@xe @C:\workspace\PeCok_Tool\memo_222dataFERG.out";
Process proc = null;
proc = rt.exec(runString1);
// proc = rt.exec("java -version");
InputStream is = proc.getErrorStream();
//InputStream is = proc.getInputStream();
int bufSize = 4096;
BufferedReader in = new BufferedReader(new InputStreamReader(is), bufSize);
String currentLine = null;
while ((currentLine = in.readLine()) != null) {
System.out.println(" " + currentLine);
}
is.close();
int a = proc.waitFor();
System.out.println(" proc.waitFor() :: " +a);
Sqlplus executes. SQLPlus window opens and and it start executing the insert satements which I have written in C:\workspace\PeCok_Tool\memo_222dataFERG.out file. But I am not able to capture the output from sqlplus window and print that in eclipse console. Somewhare in the while loop it hangs and not printing anything in eclipse console. But when I am running "java -version"(Commented in the code) It is succesfully printing java version as output in console. Now my question is how can I read the output from sqlplus window? I tried with both getErrorStream() and getInputStream().