Find current host name using Java

I am running currently on Oracle 9i app server in a clustered environment. My application has business logic that needs current host name. How can I find out the host name without externalising(like properties file) the information. Is there a java api like
.getHostName()
Rama

try this:
import java.net.InetAddress;
public class Foo {
    public static String getLocalhostName() {
        String hostName = "";
     try {
         InetAddress address =
          InetAddress.getLocalHost();
            hostName = address.getHostName();
        } catch (Exception e) {
            // error handle any which way you like
            e.printStackTrace (System.err);
        return hostName;
}cheers,
Georg.

Similar Messages

  • Need Port number for active Host name using java code

    Hi All,
    I have tnsnames string and I know one of the following Host is working  say Primary-host .
    DESCRIPTION =(ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = Primary-host)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = Secondary-host)(PORT = 1522)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = ORA112DB)))
    Could you please help me to get Port number of only primary Side ?. This needs to do because we cannot get port number using any oracle query.
    Thanks in advance
    JPrashant

    You may get client's host IP with
    select sys_context('USERENV','IP_ADDRESS') from dual;
    You may get client's port with
    SELECT port FROM v$session where username = user;
    To get connection port you should issue OS command (*nix) like
    netstat -n | grep <client_ip>:<client_port>
    tcp 0 0 192.168.1.1:1521 132.168.1.2:65432 ESTABLISHED
    To run OS command (keeping in mind all possible security consequences) it is possible to write C, java code.
    Example -- http://www.oracle.com/technetwork/database/enterprise-edition/calling-shell-commands-from-plsql-1-1-129519.pdf

  • How to find current database name i am using

    what is the command to find current database name i am using

    Dear user!
    SELECT name
    FROM   v$database;Yours sincerely
    Florian W.

  • Installing EM12c: Installer can't find database host name....?

    Hello all,
    I'm trying to install EM12c. I'm near the last steps, alll requirements passed.
    I have a fresh install of 11.2.0.3 database on a second host, listening for connections.
    But the EM12c installer keeps error'ing out saying it cannot find the host name for the database server.
    I can ping that same server name (I've quadruple checked to make sure it is right)....I've cut from the installer and pasted into a ssh session both as root and oracle user on the target GRID/EM install server...it pings just fine.
    ON the database server, I've done tnsping..and it shows listener is up, I've entered valid ports and host name.
    ON the target EM server, I've even entered in the /etc/hosts file...the IP and server name....still to no avail.
    Any suggestions out there on what else to check? I have downloaded and using the latest EM12c install media...I downloaded it about 2x weeks ago...so, should be latest patched version.
    Thanks in advance,
    cayenne
    ps. Sorry...both EM and database server are on RHEL5 These are VMWare VMs....

    mnazim wrote:
    Please paste the listener status and paste the value that you have entered at database connection screen.Ok.
    I'm having to edit out the actual server and SID names, but they do match:
    [oracle@servername ~]$ lsnrctl status
    LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 03-MAY-2012 14:45:12
    Copyright (c) 1991, 2011, Oracle. All rights reserved.
    Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
    Start Date 02-MAY-2012 19:05:49
    Uptime 0 days 19 hr. 39 min. 24 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/11.2.0/grid/network/admin/listener.ora
    Listener Log File /u01/app/oracle/diag/tnslsnr/servername/listener/alert/log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=servername.domain.name)(PORT=1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Services Summary...
    Service "instance.domain.name" has 1 instance(s).
    Instance "instance", status READY, has 1 handler(s) for this service...
    Service "instanceXDB.domain.name" has 1 instance(s).
    Instance "instance", status READY, has 1 handler(s) for this service...
    The command completed successfully
    The connection info on the EM12c Installer screen,
    Database Host Name: servername.domain.name
    Port : 1521
    Service/SID: instance (Note, I've tried this with instance name simple and with FQDN attached, same error)
    SYS Password: *************
    Thank you,
    cayenne

  • How to get the current function name in java

    How to get the current function name in java.
    In c it is done as
    printf("%s",__func__);
    Thanx in advance.

    j0o wrote:
    System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
    "/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
    "/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
    I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes!

  • How to find out query name using Elements of the query builder.

    Hi SDNers,
    how to find out query name using Elements of the query .
    thanks,
    satyaa

    Hi,
    For having a look at the relation between BEx tables,check the link below:
    http://wiki.sdn.sap.com/wiki/display/BI/ExploretherelationbetweenBEx+Tables
    -Vikram

  • How to find the File name using the FTP Adapter

    hi all,
    how to find the File name using the FTP Adapter with BPEL.
    Regards

    Found the solution for this.
    First In the mediator's routing rule use assign property $in.property.jca.file.FileName to $out.property.jca.file.FileName
    In the BPEL's receive activity go to the properties tab and get the property to a BPEL variable. That should do it.
    Thanks for the posts

  • How to find Logical database name using selection view

    Hi Experts,
                      How can we find logical database name using selection view in se36.
    Regards,
    Mani

    Hi,
    If you want to see the logincal database used in the report ( tcode se38) in the intial screen select the attribute tab
    and click display you will bw able to see the logical datbase ysed for the report.
    Thanks.

  • How to find the query name using infoset name

    Hi Experts
           Iam new to the sap queries(SQ01,SQ02), some queries already created.
          now i want to do some modification, my problem is i am not able to find the query name.
          I know the infoset name, can you tell me how to find the query name using the infoset name, is ther any table for this.
    i tried in sq01 also, but its confusion, pls advice me on this.
    thanks in advance.
    regards
    rajaram

    Hi
    try like this..
    SQ02 --> go to --> Query Directory..
    from there you can get all the queries belong to a Infoset.

  • How to find current user name on a LAN machine....

    how to find current user name in a remote machine in LAN .
    how to find current user name on a local machine in LAN .

    how to find current user name in a remote machine in
    LAN .Many users may be logged on concurrently on the remote machine.
    how to find current user name on a local machine in
    LAN .The user who is running the code in the process would be obtainable via:
    System.getProperty("some property goes here");
    I leave it to you to look at the API documentation for System.getProperties() to see what property name you would retrieve.

  • Display current page name using API ?

    I want to display the current page name using a PL/SQL API. I can get it using smart text - current page item, but I need to get it programmatically using a procedure. Which one? What variable? If I need to pass values in, where do I get them?
    Thanks,
    John

    You can use wwpro_api_parameters.get_value('_pageid','a') in a pl/sql item or UI template to get the value of the current page id. You can then use the page id to look up page attributes in the WWSBR_ALL_FOLDERS view. In a portlet, you have to use the reference_path instead of the 'a' as the second parameter.
    Please note that is is an undocumented use of this API and is not guaranteed to work in future releases. However, it does work in 9.0.2 and 9.0.2.6. WWSBR_ALL_FOLDERS is not officially supported until the 9.0.2.6 version.
    Regards,
    Jerry
    PortalPM

  • How can I find the Host Name and Instance #

    I am having trouble finding the host name and instance #. Thanks in advance.

    Hi Kyle,
    Hope you are doing good.
    if it is the R/3 server, the easiest option would be to navigate to /nSm51 .  
    Hope this helps.
    Kind Regards,
    Hemanth
    SAP AGS

  • How do I "scan" my LAN and find the host name of the server computer?

    I need to scan my LAN to find out the IP and host name of the computer in which is waiting for client acceptance because the server side of my program is not always on the same computer. Therefore, the IP and host name of my server is not final and can be placed on any computer on my network with over 50 connected computers. How might I check to see which computer is waiting for a client?
    EDIT: I need the host name only, disregard IP
    Thanks!

    watwatacrazy wrote:
    jwenting wrote:
    Peter__Lawrey wrote:
    If you know the port you can try to connect to each of the machines in turn.the people getting firewall warnings about intrusion attempts would just love that, as would the network admins whose network you're clogging with traffic (imagine several hundred clients doing that all day long, let alone tens of thousands).
    If they are all one the same subnet you can use the IP addresses.Which you don't necessarilly all know. Or do you propose just sweeping through all possible IP addresses in the subnet's range? That would be a sure trigger for your network admins to immediately kick you out.
    This should take a few seconds at most.Until the automatic safeguards kick in and you're thrown off the net :)In that case, what would you suggest?Not to bother. The server address should be part of the application configuration, not guessed at runtime.

  • Finding drives of computer using java

    Hello All,
    I am writing "explorer" using java . I am unable to find API that will
    let me find the drives of a pc. E.x :- c:\ d:\ etc...
    A computer can have any number of drives .
    Please tell me what I should do.
    Any help will be appreciated. Thanks in advance
    sameer

    Try the listRoots method in java.io.File .

  • AddNode cannot find Virtual Host name

    Hi,all;
    I want to replace a server in RAC for example RAC1. at first,I deleted node RAC1,this step is total clean out all information of RAC1 in the cluster.
    then prepare new machine of RAC1 for cluster install.
    When I run addNode.sh in RAC2 to re-add clusterware to RAC1. the first step of addNode is fill up the information of new node,Public node name,Private node name,Virtual host name.
    It will list such info of the remain node also.
    In my operation,It can find all info of new node which is rac2,rac2-priv,rac2-vip. but the remain node's Virtual host name is blank -- it shuould be rac1-vip.
    In this step,I still click "Next" to proceed my operation and return not any error.
    at the end of addNode.sh it will execute 3 script to end out operation of add clusterware to new node.
    the third script is to run /opt/oracle/product/10.2.0/crs_1/root.sh in the new node RAC1,
    the screen print "*Expecting the CRS daemons to be up within 600 seconds*."
    but after waited more than *6000* seconds,it returned nothing to me,It seem idle! I cancle the script manual.the result is the CRS can not run on RAC1.
    in RAC2,crs_stat -t can see ora.rac1.gsd , ora.rac1.ons , ora.rac1.vip. but they are all offline.
    and run vipca in RAC2 reture
    ora.rac1.gsd has placement error
    ora.rac1.ons has placement error
    has not more detail log file left in server.
    I think all of my operation is normal and In line with the rules except it cannot export remain node's Virtual host name.
    How to fix it? any ideal?
    thank you.

    [oracle@RAC1 ~]$ cluvfy stage -pre crsinst -n rac1
    Performing pre-checks for cluster services setup
    Checking node reachability...
    Node reachability check passed from node "RAC1".
    Checking user equivalence...
    User equivalence check passed for user "oracle".
    Checking administrative privileges...
    User existence check passed for "oracle".
    Group existence check passed for "oinstall".
    Membership check for user "oracle" in group "oinstall" [as Primary] passed.
    Administrative privileges check passed.
    Checking node connectivity...
    Node connectivity check passed for subnet "192.168.1.0" with node(s) rac1.
    Node connectivity check passed for subnet "10.10.10.0" with node(s) rac1.
    Suitable interfaces for the private interconnect on subnet "192.168.1.0":
    rac1 eth0:192.168.1.100
    Suitable interfaces for the private interconnect on subnet "10.10.10.0":
    rac1 eth1:10.10.10.1
    ERROR:
    Could not find a suitable set of interfaces for VIPs.
    Node connectivity check failed.
    Checking system requirements for 'crs'...
    Total memory check passed.
    Free disk space check passed.
    Swap space check passed.
    System architecture check passed.
    Kernel version check passed.
    Package existence check passed for "binutils-2.15.92.0.2-13".
    Group existence check passed for "dba".
    Group existence check passed for "oinstall".
    User existence check passed for "nobody".
    System requirement passed for 'crs'
    Pre-check for cluster services setup was unsuccessful on all the nodes.

Maybe you are looking for

  • TS2570 Safari V6 crashes at start up on OSX 10.8?

    I'm new to Apple support communities and "must choose a community" only goes to Snow Leopard v10.6! Hope someone can help. I've just upgraded OS to v10.8. I'm experiencing a problem of Safari crashing on my MacBook Pro start up from shut down with Mo

  • How to increase the memory of oracle

    Hi, I am having oracle database version 11.0.1.6 on windows server 2003 R2. My Server Ram size is 12 GB. select * from V$SGAINFO; Fixed SGA Size     1335136     No Redo Buffers     12529664     No Buffer Cache Size     1073741824     Yes Shared Pool

  • Can you please add some of Sublime Text features?

    Hi, there is a great list of features available in Sublime Text that is missing from Dreamweaver here: http://www.webdevdoor.com/sublime-text/advantages-sublime-dreamweaver/ In particular the multiple cursors and vertical text selecting would be my t

  • "Failed to use non CLS compliant type" when iterating SPLimitedWebPartManager.WebParts

    Hi, I having trouble updating a property of a custom web part with PowerShell, that is installed on a client's environment. The custom web part has a property called RowLimit for which I need to set an integer value.  Basically what my script does is

  • Simple smb question... I think

    I am trying to share home directories to windows users through smb. I have a share point set for /Volumes/disk1/home1 (user dirs all reside in home1/). However, users can not connect with their user names and passwords. Do I have to have a share poin