Solved

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

Posted on 2001-06-20
3
2,240 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 50 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 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