Solved

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

Posted on 2001-06-20
3
2,250 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

705 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