Find oracle_home location from java

What would be the best way to find oracle home and tnsnames.ora from java? In fact, I am trying to get a list of tns entries and display them in a software combobox.

+3
source share
3 answers

No auto search. If you want the Oracle JDBC driver to use your tns names, you must define a system property (-D) oracle.net.tns_admin=<directory where tnsnames.ora is located>. I recommend setting it up so you can use it, and ojdbcwill use it too (if necessary)

+2
source

tnsnames.ora is located at ORACLE_HOME/network/admin. The code will be:

String oracleHome = System.getenv("ORACLE_HOME");
if(oracleHome != null){
     String tnsFilename = oracleHome + File.separatorChar + 
                       "network" + File.separatorChar + 
                       "admin" + File.separatorChar + 
                       "tnsnames.ora";
}
+1
source

ORACLE_HOME envinroment, System.getenv("ORACLE_HOME"); .

javadoc.

0

All Articles