Replacing Host Name and Port number throughout Environments

So I am currently working on a project that have several classes using simple JDBC code. I'm switching all of it to use JNDI instead of what is currently being used. I'm using Weblogic and the plan is to have the code run in a cluster.
Here is a code Snippet of some of the code.
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://hostname:port");
My problem lies in the the "t3://hostname:port" String. I don't want to hardcode that since I know its bad code practice but my question is what is the best way to replace that with the Host Name and Port number as I move environments. Should I have a Class with a Static Variable and just reference that through the other classes or should I put it in some Property file and read the value from there? Any insight into this would be greatly appreciated.
Thank you.

would it be something like this?
Properties properties = new Properties();
          try {
     properties.load(new FileInputStream("src/jndi.properties"));
     String url = properties.getProperty("url");
     System.out.println(url );
     } catch (IOException e) {
     }

Similar Messages

  • Getting host name and port number from application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • Getting host name and port number from an application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • How to get the Host name and port number

    Hi all,
    I am working in xRPM. I need to get the server name, host name & port number for the portal and i need to diaplay as a link in the Workflow step. I cant give the portal link as static, as it will vary depends on the DEV, QUAL, PROD. Is there any FM or class is available, so i can get the server name, port no. for my purpose?.
    Regards,
    Vinoth

    Hi Kanagaraja,
    My client has configured the portal and backend in different stack. So when i execute the FM you provided and with class: CL_HTTP_SERVER, CL_WD_UTILITIES, i am getting only the backend host name and port no. not the portal's info. So please help is there any way we can get the portal's info.
    Thanks for your reply.
    -Vinoth

  • Find host name and port number using query

    Hi,
    How do find the system_name, host_name and port no
    using sql query or data dictionary.
    plz

    SELECT i.instance_name, i.host_name, f.release_name RELEASE, i.version, k.patch_level FROM
    v$instance i, fnd_product_groups f, fnd_product_installations k WHERE
    UPPER(SUBSTR(i.instance_name, 1, 4)) = UPPER(SUBSTR(f.applications_system_name, 1, 4)) AND
    k.application_id = '200';

  • Getting WLS host url and port number

    Hello Experts,
    I need to forward an authenticated request to JAAS LoginModule. How can I get wls host name and port numbe in the LoginModule?
    Thank you in advance,
    Thanks for reading my post

    Hi friends.
    I have used the last post, but it is not working.
    Mat be the API had changed.
    What class or interface could give me this data in web dynpro component?
    Too, I'm using the SAP NetWeaver Developer Studio
    Version: 2.0.16
    Build id: 200602130353
    Thank you.
    Manuel Loayza
    Living La Vida JAVA
    Edited by: Manuel  Loayza Gahona on Jul 23, 2008 6:54 PM

  • ITS host name and port.

    Hi Experts,
    What is integrated ITS host name and port for portal services? Where can I find the ITS Parameters to create a SYSTEM in Portal?
    Regards,
    Amit.

    Hi Amit,
    GO to SMICM toce in R3 system and clcik on (F) servicess button , u will get ITS host path and port number .
    GIve this details in System object ITS .
    ITS  host name : from SMICM
    ITS path should be /sap/bc/gui/sap/its/webgui
    Surekha.

  • Configuring server name and port number through action links - obiee11g

    Is it possible to configure host name and port when using action links ?
    Say some session variables hold these values. Is there any way to use these values ?
    Thanks
    SM

    Any pointers ?

  • SMICM and WAS host name and port

    Hi all,
    Can someone please throw some light on the activity WAS host name and port in port... the question is:
    Q. The information about host name and port is available in Tx SMICM, looking there in my case I find port 80xx whereas the portal runs on port 500xx. What value should we enter in the port field of "Connecting to a WAS system" in portal?
    Is it what is given in SMICM or we should use 500xx?
    Regards.

    (80xx assuming you're starting Web Dynpro ABAP apps, integrated ITS and BSPs.)
    Thanks Michael,
    How about in case when it's not ABAP it's java apps i.e. when we are connecting BI to portal with SSO on dual stake. BI uses the 500xx port on FQDN and thus it's confusing me, whether to use 80xx or 500xx (when 500xx seems the port in use on BI portal).
    Hope I made my point clear.
    Regards.

  • Application server name and port number

    Hi
    Is it possible to get the application server name(ip) and port number at runtime. Becuase i want to open an html file which is in the application server, when a button is pressed by using web.show_document ();
    Can anyone guide me please.
    Thanks in advance
    geethu

    application server name and port number

  • How to get Host name and port inside UDF

    Hi,
    I want to access the Host and port in UDF to pass it to a link http://host:port/AdapterFramework/ChannelAdminServlet?party=&service=&channel=*&action=status dynamically.
    How can I acieve it?
    Manisha

    Hi
    With this code. I am getting error:
    try
    java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
    String host = addr.getCanonicalHostName();
    catch (UnknownHostException e){}
    if (ProcessMode.equals("P"))
    try{
    String xyz="/AdapterFramework/ChannelAdminServlet?party=&service=&channel="Name"&action=stop";
    URL server = new URL("http", host, 8XXX, xyz);
    tring userPassword =Userid + ":" + Password;
       String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
        URLConnection uc=server.openConnection();
        uc.setRequestProperty ("Authorization", "Basic " + encoding);
        BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
         while ((inputLine = br.readLine()) != null)
         output+=inputLine;
        br.close();
    catch (Exception e){}
    ERROR:
    cannot resolve symbol
    symbol : variable host location: class com.sap.xi.tf._MM_CommunicationChannel_Stop
    _ URL server = new URL("http", host, 8xxx, xyz);
    ^ 1 error
    Any other way to get host and port?
    Manisha

  • Suggestion for new version: SID name and port number

    Hi, I suggest that XE 11g installer optionally request a name from SID (XE by default) and a port number (1521 by default), it would be easier to have two different editions of Oracle Database on the same machine.
    Roberto
    Edited by: rober584812 on Apr 3, 2011 2:41 PM

    >
    Hi, I suggest that XE 11g installer optionally request a name from SID (XE by default) and a port number (1521 by default), it would be easier to have two different editions of Oracle Database on the same machine.
    >
    Please Read Me
    >
    Quote from manual:
    Only one installation of Oracle Database XE can be performed on a single computer. This does not affect any existing installation or new installations of Oracle Database 11g Standard Edition, Oracle Database 11g Standard Edition One, or Oracle Database 11g Enterprise Edition.
    >
    Regards,
    Phiri

  • SOA 10g: Dynamic Host Name and Port in FTP Adapter

    Hello All,
    I am using GET operation in FTP Adapter. I wanted to make Hostname,portName,Username and Password Dynamic.
    Pls suggest how to achieve this in SOA 10g.
    thanks,
    Ab

    or http://blogs.oracle.com/adapters/2010/04/changing_the_connection_factory_jndi_dynamically_in_ftp_adapter.html
    the make the jndi dynamic, but you still have to setup all the jndi lookups before you can dynamically can change them

  • Host/server name and port

    Hi,
    is there like session/repository variable that holds the server/host name and port? i would like to get these values programmatically.
    thanks.

    In my humble opinion do not see any use in setting up these details on variables. The fact that these could be used only after logging on, which will obviously need these details manually. If you require it for tracking purpose, You could do it manually, as they are going to be static at least for that session.

  • What is MS SQL DB host name and DB port number ?

    i just installed HP quality center and ms sql 2008.Now hp quality center need to connect to my my ms sql database its asking me for database host name and data base port number.please help me out how can i find that.
    Thanks

    Click Start >> Run
    For SQL Server 2005 Type "SQLServerManager.msc" and click OK
    For SQL Server 2008 Type "SQLServerManager10.msc" and click OK
    This will Open the SQL Server Configuration Manager for you.
    Now in the Left Pane, expand "SQL Server Network Configuration" and click on "Protocols for <InstanceName>"
    Now In the right pane, right-click on the "TCP/IP" protocol and go to properties - In the bottom there is TCP port - 1433(This is default) if your sql instance is other than default it will be dynamic port.
    For host name RUN>>CMD>hostname>> this will provide host name of the server.

Maybe you are looking for

  • Is there a way of protecting PDF documents from printing and/or copying?

    Does anybody know a way of protecting PDF documents from printing and/or copying? All this within the OS possibilities? Is there a way? know one can buy expensive programmes like from Adobe, but I use it so little that I would like a cheaper solution

  • Date Format in Oracle 11g XE

    Hello everyone, I have installed Oracle11XE and noticed that it has the following date format:       SQL> SHOW PARAMETER NLS_DATE_FORMAT       NAME                                 TYPE        VALUE       nls_date_format                      string   

  • Error "Protocol [REMOTE_JDBC] not supported." while logging WORKSPACE ADMIN

    Hi All, I am trying the create a seperate domain for workspace admin, which is deployed in the Weblogic server. When I try to login, I get the error "Protocol [REMOTE_JDBC] not supported". Am I missing some configuration? Thanks in advance. Regards,

  • Windows 2008 R2 + Remote Desktop Web Access + Single Sign-On + 2 servers

    Hi First sorry for my English. I have got problem with run SSO with RDWeb. I configured everything follow this instructions:  http://blogs.msdn.com/b/rds/archive/2009/08/11/introducing-web-single-sign-on-for-remoteapp-and-desktop-connections.aspx and

  • Help need on how to load lov accoding to the locale value select

    Hi, My scenario is , i'm having two button. One button for English locale(En) and another button for Dutch locale(Nl). I'm having a database table which hold 2 columns, which are En and Nl. I'm loading this columns value using an Lov when i click the