String cmd="sqlplus username/password@sid @c:/test.sql > c:/test.log";
try {
Process pr = Runtime.getRuntime().exec(cmd);
pr.waitfor();
} catch (IOException e) {
e.printStackTrace();
}
Java调用SQL*Plus示例
本文提供了一个使用Java程序调用Oracle SQL*Plus执行SQL脚本并捕获输出的日志示例。通过Runtime.getRuntime().exec()方法来启动SQL*Plus进程,并将SQL命令与脚本文件路径作为参数。
String cmd="sqlplus username/password@sid @c:/test.sql > c:/test.log";
try {
Process pr = Runtime.getRuntime().exec(cmd);
pr.waitfor();
} catch (IOException e) {
e.printStackTrace();
}
1578

被折叠的 条评论
为什么被折叠?