I want to connect to Oracle as SYS
from SQL*Plus in Java. But I am not able to connect.
But I am able to connect as user named SCOTT
. My code snippet i
You can easily call sqlplus from java like below.
String stringCommand =
"sqlplus " + dbUser + "/" + dbPassword + "@(description=(address=(protocol=TCP)" +
"(host=" + dbHost + ")(port=" + dbPort + "))(connect_data=(service_name=" + dbName + "))) " +
"@" + sqlScriptFile + "";
int exitCode;
Runtime rt = Runtime.getRuntime();
Process process = null;
try {
process = rt.exec(stringCommand);
exitCode = process.waitFor();
} finally {
process.destroy();
}