?
Solved

how to get  TNSNAMES entries list using java to access oracle?

Posted on 2001-06-20
3
Medium Priority
?
2,279 Views
Last Modified: 2013-11-24
hi everybody,
  I try to use oracle oci driver to connect oracle database with java servlet, but at first, I try to get the local machines' all TNSNAMES entries from \orahome\transname.ora, I implemented it by parsing this file, but as you know, it is not good, because different machine has different orahome,anybody have a good idea to get those entries and put them into a JComboBox?
thanks
0
Comment
Question by:lisayan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 

Accepted Solution

by:
hasselstromk earned 150 total points
ID: 6210704
You could check the operating system, if NT get ORACLE_HOME via registry, then parse file.  If UNIX, get ORACLE_HOME via env variable, then parse file.

Hope this helps.
Keith Hasselstrom
0
 

Author Comment

by:lisayan
ID: 6211462
thanks, hasselstromk, could you tell me how get ORACLE_HOME via registry using java?
0
 

Expert Comment

by:hasselstromk
ID: 6211974
lisayan,

OK...what a lessoned learned.  I had some time to kill so I think I can help out.  I found a package that allows access to the registry.  I downloaded the zip file.  But the package is called JNI Registry.  I can return email you a copy.  My email is kmhasselstrom@tasc.com.  After setting up the class names it was very easy to traverse the registry.  

The code to get my Oracle home on my windows 2000 box is posted below.  I have several Oracle installs so you may want to write some code to read all the Oracle homes and get all the values.  Then look for several TNS names etc....

If you get a java.lang.path error try this url for help:
http://www.visi.com/~gyles19/fom-serve/cache/95.html

Hope this helps...
Keith

import java.util.*;
import javax.naming.*;
import com.ice.jni.registry.*;

public class WinRegAccess extends Object {


public static void main(String[] args) throws RegistryException{

 RegistryKey reg = Registry.HKEY_LOCAL_MACHINE.openSubKey("SOFTWARE");
 RegistryKey reg2 = reg.openSubKey("ORACLE");
 RegistryKey reg3 = reg2.openSubKey("HOME2");

 System.out.println(reg3.getStringValue("ORACLE_HOME"));

}

}
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question