barnarp
asked on
Reading Oracle database alias information
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
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
ASKER
I am looking for javacode.
Cannot run selects as I am not connected to the database yet.
Cannot run selects as I am not connected to the database yet.
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
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
From this:
https://www.experts-exchange.com/questions/20781495/listing-database-names-and-table-names.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 :-(
https://www.experts-exchange.com/questions/20781495/listing-database-names-and-table-names.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 :-(
ASKER
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
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
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
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
ASKER
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
CMM6.WORLD =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(Host = MP2HC203)
(Port = 1521)
)
)
(CONNECT_DATA = (SID = CMM6)
)
)
Not the same as ini
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did that work then?
Cool :-)
Good luck with it!!
Tim
Cool :-)
Good luck with it!!
Tim
ASKER
I got it running in the command line, but don't know how to get it working in JSP yet?
SELECT datname FROM pg_database;
work?