Oracle host details given a service name

Hi,
I have requirement of obtaining Oracle host details( IP, Port, SID) given a service naming (tnsname). I want to do it programmatically in VB/VC++ (Windows).
How can I do this?
One approach that I tried is reading the Oracle_Home from registry, then locating the tnsnames.ora file in the Oracle_Home, and reading the information from the file.
This works fine when user has tnsnames.ora file at the default location. But we are facing problem when user has multiple oracle homes or when the tnsnames.ora file is not at the default location.
I would like to know if there is a better approach than this to solve this problem.
Can some oracle API help in solving this problem.
Please help me in this regard as I am stuck for more than week on this problem. I did search in google but could not find anything relavant so far. So please help me.
Thanks a ton,
Subrahmanyam.

This works fine when user has tnsnames.ora file at
the default location. But we are facing problem when
user has multiple oracle homes or when the
tnsnames.ora file is not at the default location.Hi,
Set up a TNS_ADMIN environment variable that points to the directory where tnsnames.ora file is.
Into this file, you can have multiple database in different version.
Nicolas.

Similar Messages

  • Service Name Replacing SID?

    The following excerpt from JDBC FAQ suggest that Oracle is replacing SID with Service Name (http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html)
    "Oracle is replacing the SID mechanism for identifying databases with a new services approach. This has been available in the database since 8.1.7. JDBC supports services in the connect URL. We strongly encourage everyone to transition from SIDs to services as quickly as possible as SID's will be cease to be supported in one of the next few releases of the database."
    Can we safely assume that all DB (version > 10g) will have Service Name configured by default ? Which one is more commonly used SID or Service Name ?

    If I am correct, since 8i , Oracle is recommending people to go for Service name notation than the SID notation. Service name notation is the latest notation from sql*net protocol and SID is the older one. From 10g onwards, with the RAC incorporting services all over, service concept is now almost everywhere in the database. So yes, you should switch over to the service name than the sid notation wherever required.
    HTH
    Aman....

  • How to get service name and listening host to connect to oracle DB server?

    I have successfully installed oracle db client 10g release 2 on my winXP. But when I tried to use Net Congiguration Assistance to connect to oracle db server. I do not know what is the "service name" and listening "host" I supporse to enter. Where can I get the names?
    PLEASE HELP! THANKS!

    machine name or IP = machine name or IP address of the database server
    To know the service name do the following on the server :
    $ lsnrctl services
    LSNRCTL for Linux: Version 10.1.0.3.0 - Production on 30-DEC-2005 00:24:28
    Copyright (c) 1991, 2004, Oracle.  All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
      Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
        Handler(s):
          "DEDICATED" established:0 refused:0
             LOCAL SERVER
    Service "test10" has 1 instance(s).
      Instance "test10", status READY, has 1 handler(s) for this service...
        Handler(s):
          "DEDICATED" established:0 refused:0 state:ready
             LOCAL SERVER
    The command completed successfully
    $The service name is test10 in my case. Of course you have to use yours.

  • Getting SID with a given service name or host

    Hi.
    I am curious if there is a way or command line to get SID with a given service name or host. I have a service name, but I don't know how to get SID. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.

    caesarkim wrote:
    Is there a way to take care of it as one command something like this?
    sqlplus username/password@localhost "SELECT NAME FROM V$DATABASE@SERVICE_NAME"
    Thanks.Make a text file, dbname.sql, that contains lines below
    spool sid_name.txt
    SELECT NAME FROM V$DATABASE@SERVICE_NAME;
    spool off
    exit
    then invoke it like below
    sqlplus username/password@localhost @dbname.sql

  • Getting host, port from the tnsnames.ora with the service name

    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.

    caesarkim wrote:
    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.Oracle RDBMS does not require SQL*Net to operate.
    Oracle RDBMS does NOT now or care about content of any tnsnames.ora file.
    Realize that each (remote) user can have their own personalized copy of tnsnames.ora
    The content of tnsnames not NOT have to reflect any reality.
    I could post the content of my tnsnames.ora & it would be useless to everyone reading.

  • Host name, port number and service name

    Hi!
    I have a question that will sound easy and stupid, but not for me.
    during the instal of 9iAS.There is a screen ask to provide the host name,port number and service name.
    Did host anme is only the name of my PC?
    and what is the port number?(windows XP)
    what is the format of the service name (orcl)?
    Thanks
    Kamal

    if you used LDW as the connection/service name when you setup this connection to CMS DB, then no further changes to BOE configurations will be needed.
    If you used the service name PO and now it is changes to NEW_PO - then you'll have to update CMS DB connection info in CCM>SIA>Properties>Connection.
    See Admin guide for details.
    p.s.
    BOE services should be stopped while your changes on Oracle side are done and before you change the TNS file and connection info in CCM.

  • Web Services Tutorial on Oracle Hosted free HTML DB platform

    I was told before that web services would not be supported for a while on Oracle Hosted free HTML DB platform.
    Is there any new status info about this?

    Dave, given the messages returned indicate your configuration is looking at a j2se1.4 directory, I think that is the problem. Neither OC4J or JDeveloper are certified with JDK 1.4. I realize that you have installed 1.3 so my guess is that in following step 8 and 10 of the "Installing and Running Oracle9iAS Containers for J2EE" where it says:
    8. Install the J2EE container using the following command: java jar oc4j.jar install
    10. Start the J2EE container by issuing the following command: java jar oc4j.jar Show me.
    the problem is that the commands were not prefixed with the location of your JDK 1.3 installation and by default picked up the later JDK 1.4. I think you will be able to get around it by running the commands as follows (replacing directory names by your locations):
    <jdk1.3_home>\bin\java -jar oc4j.jar -install
    <jdk1.3_home>\bin\java -jar oc4j.jar
    Your JDeveloper should be fine unless you changed its JDK to also be 1.4; by default it uses its own built-in 1.3 JDK.
    Hope this points in the right direction.
    Mike.

  • Oracle 9i "TNS:could not resolve service name" on 64-bit OS

    I have a 32-bit .NET 3.0 application that can run on 64-bit OS using WOW64. When I connect to the database on 32-bit OS with 9i (9.2.0.1) client, everything works fine. However, if I install the same client on 64-bit OS (assuming that it would run using WOW64) and run the application, I get "TNS:could not resolve service name" error.
    To make sure that it's not something with configuration, I've installed both clients in the same directory on 32-bit OS and 64-bit OS, and copied the same tnsnames.ora and sqlnet.ora files. I can also connect to the database without a problem on 64-bit OS using SQL Plus. The error only occurs when connection is made via the application, which uses .NET oracle client. The only main difference is that on 64-bit OS, 64-bit version of .NET 3.0 is installed.
    Does anyone have an idea why I am getting this error?
    [tnsnames.ora]
    TRADMIN.ASCINDIA.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.253.57.44)(PORT = 1521))
    (CONNECT_DATA =
         (SID = TRADMIN)
         (SERVER = DEDICATED)
    [sqlnet.ora]
    # SQLNET.ORA Network Configuration File: D:\Oracle\Ora92\network\admin\sqlnet.ora
    # Generated by Oracle configuration tools.
    NAMES.DEFAULT_DOMAIN = xxx.yyy.zzz
    SQLNET.AUTHENTICATION_SERVICES= (NONE)
    NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)
    [tnsping on 32-bit OS]
    Used parameter files:
    D:\Oracle\Ora92\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.253.57.44)(PORT = 1521))) (CONNECT_DATA = (SID = TRADMIN) (SERVER = DEDICATED)))
    OK (640 msec)
    [tnsping from 64-bit OS]
    Used parameter files:
    D:\oracle\ora92\network\admin\sqlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.253.57.44)(PORT = 1521))) (CONNECT_DATA = (SID = TRADMIN) (SERVER = DEDICATED)))
    OK (590 msec)

    Hi, paste in this post your tnsnames.ora and sqlnet.ora files and give us a example tnsping for test your alias database.
    Good luck.
    Regards.

  • Permission required to access oracle client service names

    Hello,
    I  actually have a problem with accessing oracle client service names in Crystal.
    The problem is:
    I installed crystal reports 2008 and installed oracle client on a machine (I used an account that is a local administrator of the machine during installation) but the problem is that the users who are going to access crystal are standard users and they couldnu2019t access the services in oracle client and when they try to refresh the report they get the following error
    "Failed to load database information. Details: the DB connector 'crdb_oracle.dll' couldn't be loaded. the correct version of the database client for this database type might not be installed"
    I gave the users permission on the two folders (C:\program files \Common files \) and RegEdit : (C:\Windows \ System 32\) but the problem wasnu2019t solved so I made them local administrators and the problem was solved but I donu2019t want to make the users  local administrators on the machine , some people told me that I have to install oracle client with the user who will be using crystal but the problem is that two users will be working on the machine not just one and they have two different accounts and when I tried to give the users full control permission on oracle folder , the problem wasnu2019t solved, So I wanted to know if any one faced a similar problem and how to solve it without making the users local administrators.
    Thanks in advance.

    Hello,
    It appears you have everything installed and configured for Cr to work so it looks like it's a DB issue.
    What do you see in the logs if you enable logging on the Server? Are your requests even getting to the Server from CR under the user account?
    Test it using the admin and then the user account.
    You could try checking on the option to use Trusted Authentication in the database log on windows of CR. This should pass the users PC log on credentials to the Server.
    Thank you
    Don

  • How to connect to Oracle 11g using thin driver with service name & SID

    Hi Experts,
    Wish to know whether there is a common way to connect to Oracle 11g server using SID or service name.
    Earlier I used jdbc:oracle:thin:@<<server>:<<port>>:<<SID>> for connecting to individual Oracle server instances.
    Now I need to connect to Oracle RAC which provides service names. So I need to use jdbc:oracle:thin:@<<server>:<<port>>/<<service name>>.
    This connection string is internally constructed by a program and user inputs <<server>>, <<port>> and <<SID>> or <<Service Name>>. Now this requires two different connection strings based on the input whether its SID or service name.
    Is there a common connection string for these two? Based on some articles like this, I understood that we can generically use jdbc:oracle:thin:@<<server>:<<port>>/<<service>>, whether for SID and service.
    When I tried this format with SID, I am getting the below error. What I tried is jdbc:oracle:thin:@myoracleserver:1521/ORCL, where ORCL is the SID
    java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
    Request your help in solving this. What I want is a single connection string whether its SID or service. Any help is of great value.
    Regards
    Sunil

    Wish to know whether there is a common way to connect to Oracle 11g server using SID or service name.
    Earlier I used jdbc:oracle:thin:@<<server>:<<port>>:<<SID>> for connecting to individual Oracle server instances.
    Now I need to connect to Oracle RAC which provides service names. So I need to use jdbc:oracle:thin:@<<server>:<<port>>/<<service name>>.
    This connection string is internally constructed by a program and user inputs <<server>>, <<port>> and <<SID>> or <<Service Name>>. Now this requires two different connection strings based on the input whether its SID or service name.
    Is there a common connection string for these two? Based on some articles like this, I understood that we can generically use jdbc:oracle:thin:@<<server>:<<port>>/<<service>>, whether for SID and service.
    When I tried this format with SID, I am getting the below error. What I tried is jdbc:oracle:thin:@myoracleserver:1521/ORCL, where ORCL is the SID
    java.sql.SQLException: Listener refused the connection with the following error:
    ORA-12514, TNS:listener does not currently know of service requested in connect descriptor
    Request your help in solving this. What I want is a single connection string whether its SID or service. Any help is of great value.
    Oracle has an entire book for JDBC: The JDBC Developer Guide.
    There are chapters that provide ALL of the connection properties and the rules for creating connection urls.
    http://docs.oracle.com/cd/E11882_01/java.112/e16548/urls.htm#BEIDBFDF
    See table 8-3 in that doc

  • Database Service Name or Global Database Name with Oracle 10G, when Oracle

    I have an old installation of Oracle 9i (SID=ORCL) and now have installed Oracle 10G (SID=ORC2). I can get connection to Oracle 10G if i define it as an Oracle 8 compatible identification (ie I access to a SID, and don´t provide a Service Name.
    Now I want to install Oracle HTML DB, and succeeded to install the SQL-script that came with the download, but when I install Apache and HTML DB from the Oracle Companion CD I am asked to give the Database Service Name (in the Help it is explained as the Global Database Name).
    When i give the Net Service Name I get error messages (incomprehensible).
    When I look in Net Manager, the Net Service Name does not have a Service Name, but only points to a SID (ie ORC2).
    Where can I find the Database Service Name (or Global Database Name), OR define it if it is not defined??
    Thanks for your help,

    create a net service for oracle10g and provide the name of this service during HTML DB installation it is required for installation.

  • How to know the service name of oracle server

    write a query to get the servcie name of oracle from oracle tables

    Not really! That's the instance name and not the service name!
    This version is correct:
    select name, value from v$parameter where name = 'service_names';
    NAME                                                             VALUE         
    service_names                                                    ACPT.WORLD
    1 row selectedBye, Aron

  • How to create custom service name in oracle 10g

    Hi,
    I have installed oracle 10g, it has created default servicename as XE which is having only 4GB memory size. It is not sufficient to import my dmp file. I would like to created my own service name, How can I do it.
    Advice thanks for your instruction.

    Strange...
    You'd have to read (and accept) the OTN License Agreement (or, I guess, have a "regular" license), but as stated on the main software downloads index:
    "+All software downloads are free, and each comes with a Development License that allows you to use full versions of the products at no charge while developing and prototyping your applications (or for strictly self-educational purposes).+"
    http://www.oracle.com/technology/software/index.html

  • Given IP and port number, Is there a way to find the service name?

    Hi,
    In the Java language, if I am given the IP and the Port number, is there way to lookup the corresponding service name?
    thanks, grace

    There are a number of standard services by port number. You can get that from /etc/services on any nx system and put it into a map or array. That list doesn't change all that often.
    In general though, as Dave says, no.
    Assuming the service is not one of the standard ones and the same port may provide different services on different IP addresses, there would need to be some standard protocol for naming services that you could access at those IPs--either a "list of ports/services" service that's at a known port, or a request/response that would be standard across all IPs and ports. As far as I know, neither of those exist.

  • Get port number,host name,service name from database

    Is there any way to know the host name,port number, sid and the service name of a particular instance from the database.

    > Is there any way to know the host name,port number, sid and the service name
    of a particular instance from the database.
    Why?
    The host name in the HOST_NAME column of V$INSTANCE for example, may not be the hostname/IP address that the local Listener listens for connections on. Or the Listener can listen on that host name/IP and several other local IP addresses.
    The port number used for listening for connections by clients, are determined by the Listener's configuration.
    Thus if you can explain the requirement for this info, maybe the forum can provide better and more specific answers.

Maybe you are looking for