?
Solved

Reading Oracle database alias information

Posted on 2005-04-13
10
Medium Priority
?
224 Views
Last Modified: 2010-04-01
Hi,

Is there a way to read the Oracle database entry information from the tnsnames.ora file in order to populate a dropdown of databases that the user can select which one to log in to?

Regards
0
Comment
Question by:barnarp
  • 6
  • 4
10 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 13779778
Does:

    SELECT datname FROM pg_database;    

work?
0
 

Author Comment

by:barnarp
ID: 13779966
I am looking for javacode.

Cannot run selects as I am not connected to the database yet.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13779996
Sorry, that's postgres as well I believe...

you will need to connect to the database to be able to get the list...

Maybe by creating a small test database, you will be able to connect to that, and then query the database for its metadata...

Tim
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 35

Expert Comment

by:TimYates
ID: 13780010
From this:

http://www.experts-exchange.com/Databases/Oracle/Q_20781495.html

once you connect to a database, you can apparently fire the SQL query:

     select name from v$database;

To get the list...

I have no way of testing this tho :-(
0
 

Author Comment

by:barnarp
ID: 13780104
Yes,

The query select name from v$database; works once you are connected. But I need a way to reed the .ora file (.ini type file) in the Oracle directory to determine which connections are on the pc.

Regards
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13780137
http://www.codeproject.com/useritems/INIFile.asp

will read INI files (if it is a standard windows ini file format)

Assuming you have a local copy of the .ora file

Of course, if the database is on a remote machine, you'll have to go the other route :-)

Tim
0
 

Author Comment

by:barnarp
ID: 13780457
Typical .ora file entry:

CMM6.WORLD =
  (DESCRIPTION =
    (ADDRESS_LIST =
        (ADDRESS =
          (PROTOCOL = TCP)
          (Host = MP2HC203)
          (Port = 1521)
        )
    )
    (CONNECT_DATA = (SID = CMM6)
    )
  )


Not the same as ini
0
 
LVL 35

Accepted Solution

by:
TimYates earned 400 total points
ID: 13780475
Oooooh!

Look what I found:

http://www.orsweb.com/downloads/source/447.html

and

http://www.orsweb.com/downloads/source/495.html

the second one apparently "...offers more than existing solutions have. It encapsulates the alias entries in this library for access via Enumeration or specified alias string. Methods are provided to build a connect string or access the protocol, host, port and sid separately"

:-D
0
 
LVL 35

Expert Comment

by:TimYates
ID: 13806021
Did that work then?

Cool :-)

Good luck with it!!

Tim
0
 

Author Comment

by:barnarp
ID: 13808191
I got it running in the command line, but don't know how to get it working in JSP yet?
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

829 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