• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Runtime.exec an Oracle Programs

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
This looks like a job for .... legal tender! It says so right in this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic