I would like to launch some oracle tools (SQL*plus and RMAN) from a
java client.
I have the following code
String v_aux="DB_02";
String v_src="DB_01";
String oracle_home="d:\\oracle\\ora92";
String v_path="d:\\oracle\ora92\\bin;E:\\Program Files\\Oracle\\jre\\1.3.1\\bin"+
";E:\\Program Files\\Oracle\\jre\\1.1.8\\bin;E:\\WINDOWS\\system32;E:\\WINDOWS";
Runtime rt = Runtime.getRuntime();
String v_cmd="rman target sys/xxxx@db_01 auxiliary sys/yyy@db_2";
for (int l=0;l<args.length;l++)
{ System.out.println(args[l]);}
String[] envArray={"ORACLE_HOME="+oracle_home,
"MV_HOME="+mv_home,
"ORACLE_SID="+v_aux,
"PATH="+v_path};
File f_db_dir = new File(oracle_home+"\\admin\\"+v_aux);
int el = envArray.length;
for (int x=0;x<el;x++)
{
System.out.println(envArray[x]);
}
String outPut ="";
Process p = null;
try
{
p=rt.exec(v_cmd,envArray,f_db_dir);
InputStreamReader is = new InputStreamReader(p.getInputStream());
BufferedReader stdRead = new BufferedReader(is);
while (( outPut=stdRead.readLine()) !=null)
{
System.out.println(outPut);
}
stdRead.close();
is.close();
}
catch (Exception e)
{
e.printStackTrace();
System.out.println(e.getMessage());
}
return;
}
}
Now, If I run this I get 2 problems
#1 the Oracle net8 client cannot seem to resolve the hostname portion of the tns entry. I can live with that.
#2 the oracle net8 client reports an ora-12560 error, TNS Protocol Adapter
If I try and just run sqlplus in the v_cmd (with the ORACLE_SID set in the Runtime process I can connect.
Is there a problem with sockets in Runtime Processes?