process = Runtime.getRuntime().exec(cmd,null,new File(path));
을 사용하여 파일 (abz.sql)에서 일부 SQL을 실행하고 있습니다.Runtime.getRuntime(). exec 실행 문제
명령 :
"sqlplus "+ context.getDatabaseUser() + "/"
+ context.getDatabasePassword() + "@"
+ context.getDatabaseHost() + ":"
+ context.getDatabasePort() + "/"
+ context.getSid() + " @"
+ "\""
+ script + "\"";
String path=context.getReleasePath()+ "/Server/DB Scripts";
파일을 실행하고 있지만 종료하지는 않습니다. 그러므로 나는 다음을 사용하여 시도했다.
Writer out = new OutputStreamWriter(process.getOutputStream());
out.append("commit;\r\n");
out.append("exit \r\n");
System.out.println("---------"+out);
out.close();
이것은 내가 사용하는 완전한 블록이다.
if(context.getConnectionField()=="ORACLE")
{
String cmd=
"sqlplus "+ context.getDatabaseUser() + "/"
+ context.getDatabasePassword() + "@"
+ context.getDatabaseHost() + ":"
+ context.getDatabasePort() + "/"
+ context.getSid() + " @"
+ "\""
+ script +"\"";
String path=context.getReleasePath()+ "/Server/DB Scripts";
process = Runtime.getRuntime().exec(cmd,null,new File(path));
out = new OutputStreamWriter(process.getOutputStream());
out.append("commit;\r\n");
out.append("exit \r\n");
System.out.println("---------"+out);
out.close();
Integer result1 = null;
while (result1 == null) {
try {
result1 = process.waitFor();
}
catch (InterruptedException e) {}
}
if(process.exitValue() != 0)
return false;
return true;
}
심각한 문제인 경우 다른 사람들이 내 질문을 읽는 방법을 고려하십시오. 귀하의 질문은 형식이 잘못되었고 다른 사람들을 위해 매우 열심히 읽습니다. 일반적으로 이것은 낮은 품질의 답변 또는 전혀 응답하지 않습니다. 질문에 대한 적절한 대답을 원하면 그에 대한 질문을 작성하십시오. –
어떤 방식으로 작동하지 않습니까? 예상 한 결과를 얻지 못했거나 예외가 발생하고 있습니까? – karakuricoder