Connect Oracle in different hostname and port

2012-05-09
2012-09-26
  • How to connect Oracle in different hostname and port.
    Where do I need to specify the hostname and port number while connection.

    Thanks in advance.

     
  • How to connect Oracle in different hostname and port.

    I also checked in the OCI_ConnectionCreate function, but it doesn't asks for
    hostname and port number:
    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);

    As my requirement is to connect the oracle server which resides in different
    server, and my application runs in different server.

    Thanks in advance.

     
  • Vincent Rogier
    Vincent Rogier
    2012-05-10

    Hi,

    Apparently, you're new in the Oracle world. As it is mentioned in the
    documentation, the parameter 'db' can be a full connection string or an TNS
    alias or an easy connect string.

    If theses terms means nothing to you, you can grab information on google about
    it.

    However, Here some information about it :

    the first parameter 'db' of OCI_Initialize() can be :

    1 - A TNS alias name defined in an tnsnames.ora file (if you're using a
    regular Oracle client, it is located in $ORACLE_HOME/network/admin)
    2 - A full TNS connection string (the left part of '=' in a tnsnames.ora alias
    definition)
    3 - An easy connect string (server:port/service_name), the best method if
    you're using an instant client

    Examples :

    here is a tnsnames.ora content example (I've indicated in bold the information
    that are specific to each server connection) :

    MY_ALIAS =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = MY_HOST)(PORT = 1521))
    )
    (CONNECT_DATA =
    (SERVICE_NAME = MY_SERVICE_NAME)
    )
    )

    The three ways are (I've indicated in bold the information you have to provide
    for each method) :

    1 - TNS alias name defined in an tnsnames.ora file

    OCI_ConnectionCreate("MY_ALIAS", ......);

    2 - full TNS connection string (the right part of '=' in a tnsnames.ora alias
    definition)

    OCI_ConnectionCreate("(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL =
    TCP)(HOST = MY_HOST)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME =
    MY_SERVICE_NAME)))", ......);

    3 - An easy connect string (server:port/service_name)

    OCI_ConnectionCreate("MY_HOST:1521/MY_SERVICE_NAME", ......);

     
  • Hi:
    Ok nice answer, but how can I generate ocilib if I don't have oracle client in
    my host? I mean:
    Host1 (wout/Oracle Client) ----> connect remotly ---> Host2 (w/Oracle
    Client)
    In Host1 I want to install ocilib and use the remote connectin
    I see in the manual that using the instruction:
    ./configure --with-oracle-import=runtime
    but when i use:
    ./make appears:
    ksh: ./make: not found.

    It's aix 5.2 and C compiler 6

     
  • OCILIB needs an Oracle client regular or instant (1 shared lib) in order to
    communicate with an Oracle server.

     
  • But it supposed that OCILIB can make connections to remote instances. ¿Does
    exists another way to make ocilib?

    Thanks

     
  • Vincent Rogier
    Vincent Rogier
    2012-06-22

    There is a misunderstanding...

    OCILIB need an Oracle client to work at runtime.
    But to build the OCILIB shared library, there are 2 options :
    - linking at compile time to the Oracle client shared library. In this case the Oracle client is needed at OCILIB compilation time.
    - not linking Oracle client shared library at compile time. In this case, no oracle client is need at OCILIB compilation time. Then OCILIB will dynamically loads the Oracle shared library at runtime.

     


Anonymous


Cancel   Add attachments