Use of properties file

I need to connect to a database I have specified the driver class and url in a .properties file, I have placed this .properties file in the classes folder of WEB-INF
once i create the war file and sent it to the client, They need to change the url but since we are delivering a war file they cannot do it. How can i achieve this?

Use a JNDI datasource so that your code doesn't make a connection to the database but uses JNDI to locate the datasource. Then the client only has to create the datasource at the server level and assign it to the JNDI name.

Similar Messages

  • Multiple use of properties file

    Is there a way to use a properties file for multiple languages?
    ie.
    en_EN points to the en_EN properties file
    I want en_US to also point to that, is this possible? (it now points to default language if not present)
    And anyone got a good tutorial / overview of the possibilities of properties file? have not been able to find a good example that shows all possibilities
    Thanks

    Provide an en version which contains all the English stuff, then put all the en_US and en_EN variants into those files respectively.

  • Using Search_replace.properties file

    I am trying to use Migration assistant to migrate my forms form 6i to 10g.
    While doing so , I want to use search_replace.properties file to search for soem strings and automatically replace them.
    I want to search for 'message_box(' but it is not being read due to this '(' special symbol.
    How can I include special symbols in search or replace string?

    So no reply on this thread...
    I will take look at jdapi, but with my poor knowledge of java ......
    JeanYves

  • Using Multiple Properties Files in Struts Framework

    Hi Everybody!
    I just to know how to use a multiple message-resources files in a Struts Framework.
    I've 2 properties file :
    1. ApplicationResources_A.properties
    2. ApplicationResources_B.propertiesI put the files under WEB-INF/classes dir.
    My configuration in struts-config file something like below:
    <!--  Begin Testing -->
         <message-resources key="A" parameter="ApplicationResources_A" />
         <message-resources key="B" parameter="ApplicationResources_B" />
    <!--  End Testing -->
    </struts-config>
    if my JSP code is like below , this error is thrown:
    org.apache.jasper.JasperException: Cannot find message resources under key A
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message bundle="A" key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message bundle="B"  key="user.lang.desc"/></td>
      </tr>
    but  if I change the  JSP code like below it  work fine:
      <tr>
        <td width="17%">Language A</td>
        <td width="83%"><bean:message key="user.lang.desc"/></td>
      </tr>
      <tr>
        <td width="17%">Language B</td>
        <td width="83%"><bean:message  key="user.lang.desc"/></td>
      </tr>
    In this code , I dont know  which resources file is used.
    So how do I solve this problem. Thanks you.

    I have defined the following:
    struts-config.xml
    <message-resources key="ldap" parameter="com/project/struts/ldap"/>
    Action.java
    In execute method:
    MessageResources messageResources= MessageResources.getMessageResources("com/project/struts/ldap");
    System.out.println("INITIAL_CONTEXT_FACTORY"+messageResources.getMessage("INITIAL_CONTEXT_FACTORY"));
    and it is working, however I have to change "com/project/struts/ldap" value in Action.java file whenever there is any change in name or location of ldap.properties.
    Can I access this properties in such way that I don't have to change parameter path manually in Action.java (modifying in struts-config.xml is okay)? like access through key="ldap" or something.
    Thanks and regards,

  • File I/O problems using a Properties file

    Hi,
    I am having troubles reading in a properties file. The file looks like this:
    aname=apassword:word2
    bname=bpassword:word
    ...etc
    The code I have this far is:
    import java.util.*;
    import java.io.*;
    public class LoginH
    public static void main(String[] args)
    String logon, pswd;
    //String login = null;
    //String password = null;
    //String nick = null;
    int msg = 0;
    System.out.print ("Login: ");
    logon = MyInput.readString();
    System.out.print ("Password: ");
    pswd = MyInput.readString();
    Properties settings = new Properties();
    try
    FileInputStream sf
    = new FileInputStream("LogonH.ini");
    settings.load(sf);
    catch (FileNotFoundException e) {}
    catch (IOException e) {}
    // public void whitespaceChars(58,58)
    StringTokenizer st = new StringTokenizer(settings.getProperty(logon));
    String password = st.nextToken();
    String nick = st.nextToken();
    System.out.print (password + nick);
    ** It works fine if i replace the colon in my properties file with a blank space, However i need to use a colon. I tried to set whitespaceChar to allow this but I can not seem to get it to work. Let me know if you have any ideas. Thanks in advanced.

    Thanks. I just got done doing something to that nature however now my problem is if the key field is not in my properties file my program crashes. I need to print out to the console "sorry" if my user name which is my key is not in the properties file. Here is my code if anyone can help me out:
    import java.util.*;
    import java.io.*;
    public class LoginH
    public static void main(String[] args)
    //******** Declare Variables *********************
    String userlogin;
    String userpaswd;
    String login = null;
    String paswd = null;
    String nicknm = null;
    int match=0;
    String delim = ":";
    //******** Get username and password **************
    System.out.print ("Login: ");
    userlogin = MyInput.readString();
    System.out.print ("Password: ");
    userpaswd = MyInput.readString();
    Properties settings = new Properties();
    try
    FileInputStream sf = new FileInputStream("LogonH.ini");
    settings.load(sf);
    catch (FileNotFoundException e) {}
    catch (IOException e) {}
    StringTokenizer st = new
    StringTokenizer(settings.getProperty(userlogin),delim);
    paswd = st.nextToken();
    nicknm = st.nextToken();
    if(userpaswd.equals(paswd))
    System.out.println("Ok " + nicknm);
    match = 2;
    else
    System.out.println("Sorry " + nicknm);
    match = 1;
    if (match == 0) System.out.println("Sorry");
    }

  • How to use JDBC Appender of log4j using a properties file

    Hi,
    I am trying to implement the Log4j JDBC Appender to log the messages to Database(oracle).Can anyone provide me with a sample code along with the properties file used.
    need urgent help.
    Thanks in advance

    Actually, I konw where my problem in my code is. Use functions  
    PDDocAcquirePage(), PDPageGetAnnot(),
    PDTextAnnotGetContents(),
    PDTextAnnotGetContents()
    step by step with the logic designed by ourself can finish my task.
    But also thanks for your help!
     

  • Is this how to use a properties file?

    Hi:
    The following is how I intend to create and read a properties file, please verify for me that the idea is correct.
    1. create myProp.properties
    2. in myProp, the content is like such:
    a=myA
    b=myB
    c=myC
    3. In my application,
      FileInputStream in = new FileInputStream(getClass().getResourceAsStream("/myProp.properties"));
      Properties p = new Properties();
      p.load(in);
      String a = p.getProperty("a");
      String b = p.getProperty("b");
      String c = p.getProperty("c");Thanx!

    It depends on what youare doing but if you have a set of properties that you are going to always use from one running of the application to the next, they should generally be defined as static finals.
    For example, lets say you want a configuration file for an application that holds the user's preferences. You might want something like this:
    public class Preferences {
       private static final String ALWAYS_ON_TOP = "always on top";
       private Properities preferences = new Properties();
       static {
          //load the file
       public boolean setAlwaysOnTop(boolean alwaysOnTop) {
          preferences.put(ALWAYS_ON_TOP, String.valueOf(alwaysOnTop));
       public boolean getAlwaysOnTop() {
          return Boolean.valueOf(preferences.get(ALWAYS_ON_TOP));
       public void save() {
          /save file
    }

  • Use resourceBundle properties file from KM

    Hi,
    I have a properties file called com.mycomp.apps.phonebook.properties in the KM Content of the portal in KM Content => root => mycomp => apps => phonebook => customizing
    Now I'm developing a new LinkCommand service for the UserDetails.
    http://help.sap.com/saphelp_nw04/helpdata/en/65/29b24053c13f5fe10000000a155106/frameset.htm
    The already existing LinkCommand "Send E-mail..." is read from the original resourceBundle com.sap.ip.collaboration.gwui.api.wdf.mail.SendTo
    For my new LinkCommand I would like to use the existing properties file. How do I have to define this file in the uicommand xml or properties xml sheet?
    Can anybody help me?
    With the local project resourceBundle it's working, but I would like to use the file in the KM. Andy ideas?
    Regards,
    Stefan

    Hi Praven,
    Copying all existing SendTo properties file to my project would be an option but I wouldn't win anything.
    I'm quite happy with the existing SAP collaboraton properties files using e.g. for "Send e-mail".
    I won't change this existing ones. I created a new LinkCommand. And for this new LinkCommand I'm looking for a solution how I can handle the translation for it.
    I would prefer e using my existing file which is located in the KM. The reason why it's located in the KM is, if I need to change a translation or add a new translation properties file I only need to change it in the KM. If it's a part of the project I need by every change to deploy the project new.

  • Very weird issue with server logging when using log4j.properties file

    I'm using log4j logging. In log4j.properties the root logger is set up to use the ServerLoggingAppender class so that all our application logs go to the main server logfile. In addition, there are several appenders defined for specific components, with output going to specific per-component log files. Everything is going fine until I launch the server console. At this point all of those per-component log files get wiped out (zero length) and some non-ASCII lines are written to at least one of these files, after which the logs appear to be fine. The main server log file does not appear to be affected (because the root logger is set to "warn" level, while component-specific loggers are set to trace, the contents in these files is different; however I tried disabling all the other appenders and turning the root logger up to trace, and that still did not re-create the problem in the main server log file.
    And here's the really weird part -- if I use the same configuration, but in a log4j.xml file, the problem does not happen.

    Figured it out.
    We were passing in the configuration for log4j as -Dlog4j.configuration=file:/<properties file> and this was added to the command line for both the managed and admin servers. Problem is that the console app starts its own instance of log4j, and when it reads the configuration for the appenders it initializes or rolls over the files. At some point we have two JVMs accessing the same files, so some corruption is bound to happen.
    I'm not clear why the .xml file made a difference, but earlier we had been passing the log4j configuration as a jar file placed in the domain/lib folder, so perhaps the designer reverted to that (placed the log4j.xml file in a jar in lib, and not simply changed the -Dlog4j.configuration=file:/ option.

  • Unable to configure log4j using a properties file

    So i have an xml log4j config file that i stole from JBOSS, so i know it has the correct syntax. i put this file into my project dir, and i do this in the main method:
    System.out.println(new File("crawler.log4j.properties.xml").exists()); //prints true
    PropertyConfigurator.configure("crawler.log4j.properties.xml");i have the console appender set to INFO
    I am seeing DEBUG messages.
    i searched my project for log4j* files and there are no other configs laying about.
    what am i missing?

    i should have been using DOMConfigurator instead of PropertyConfigurator

  • Localize app. using Bundle.properties files, need help

    Hi! I used tutorial to internationalize my app.:
    http://www.oracle.com/technology/products/jdev/101/howtos/jsfinter/index.html
    I use Jdeveloper 11g. Have 2 files: LocalizeKokaugi.properties and LocalizeKokaugi_en.properties. My app is internationalized, but when I need to change language then I need use IE or FireFox settings to set language. I have two questions:
    1. What I need to do to change language using my created buttons? Can You give step by step to this?
    2. Can I set VO -> Attributes -> Control Hints -> Labet Text to #{sampleBundle.myTitle}. I tried this, but then the label value don't comes from my bundle. Where is problem and what to do?
    Waiting response from You!
    Best regards

    Deniz Gulmez wrote:
    Hello,
    Is below method enough to change the locale for Application Module also? I am trying to change the locale using the below code. Messages from UI project changes as expected but Entity labels and error messages from Application Module are still in old locale.
    private void switchToLocale(Locale locale)
    FacesContext context = FacesContext.getCurrentInstance();
    UIViewRoot root = context.getViewRoot();
    root.setLocale(locale);
    It should... However I must admit that I rarely push the Locale on the model layer, it does not belongs there, even if ADF encourage that pattern, I highly dislike it and do everything in my power to not have it used in my project. Presentation language is, well, a presentation concern, so should be handled in the presentation layer, not the business one. When the model must send an information, it should be using a code and parameters that then get translated by the view.
    Regards,
    ~ Simon

  • How to load Java properties file dynamically using weblogic server

    Hi,
    We are using Java properties file in Java code. Properties in java properties file are frequently modified. If I keep these properties file in project classpath or as part of war, I will have to redeploy application after each change.
    We are using Weblogic Server.
    Can you please suggest me how can this properties file be loaded at weblogic server startup. Then in that case, how to refer property file in Java code?
    What is the best practice for this?
    Thanks,
    Parshant

    Another alternative is, keep the property file in any pre-defined location. Write a class which reads the properties from the file and returns the one which is requested by caller and deploy this class. Whenever you have to change the properties just update the property file on server and next call to fetch the property should return the updated one.
    Downside of this approach is file I/O everytime. To overcome that you can actually "cache" the properties in a hashmap. Basically when any property if requested, first check the hashmap, if not found then only read from property file and also update in hash map. Next time same property will be returned from hash map itself. The hash map will be cleared at every server restart since its in the memory. You will also need to build a method to clear the hashmap when you update the values in the property file on server.
    This solution would be suitable for small size files and when network overhead of calling a DB needs to be avoided.

  • How we write into properties file using get class method

    Hi
    I want to set some value into properties file using given code
    can any one please tell me how i can do this.
    property file
    setting.properties
    Name     =     abc
    and code I use is
    java.io.InputStream oInputStream = this.getClass().getResourceAsStream("Setting.properties");
                   Properties obj = new Properties();
                   obj.load(oInputStream);
                   String myName = obj.getProperty("Name");
                   System.out.println("myName :"+myName);
                   obj.setProperty("Name","def");
                   FileOutputStream oOutput= new FileOutputStream("Setting.properties");
                   obj.store(oOutput, "");
    thanks.

    You can't.
    If you have properties that change dynamically, you should not be using a properties file that sits in the classpath, you should be using Preferences, or a properties file that sits in some application or possibly even user directory, but not one in the classpath. The proper way to do this, would be to have a properties file in your jar (or otherwise in your classpath) that contains the defaults, and another one outside of the classpath in one of the twwo above mentioned areas, then, you read the default one only if the other doesn't exist, or you read the default one first, then read the other overwriting the values from the defaults.
    Don't forget to save the properties again (right after loading if you loaded, or always load, the defaults) after every change.

  • Text editor used to type the contents of the properties file

    ******To all those (expect iainsinclair) who view this message - Sorry for using this forum for my personal contacts **********
    Hi iainsinclair
    Thanx for explaining ur experience to me for my previous posted topic . U did mentioned a text editor called NETBEANS PROPERTY TEXT EDITOR .
    * Can u please explain more about this editor . Is this editor specific to some encodings ....
    * U said that as u enter the Japanese characters in ur keyboard the editor saves the characters in the unicode format. Are the characters displayed in their glyphs or as \u????.
    * Can u give me a list of languages f or which this text editor can be used . Bcoz u had suggested that it can be used for chinese also .
    * I need more info about a Japanese Computer and keyboard. I think we both are in the same level in this topic I18N . Iam working for I18N project in my company. This is my official mail ID- [email protected] .Can u send me ur mail Id so that we make sure that this forum members are not disturbed by our discussion .

    Hi, I'm happy if I can help.
    * Can u please explain more about this editor . Is this editor specific to some encodings ....
    It's the netbeans IDE from www.netbeans.org it's a free integrated development environment for java. It includes many editors, for .java files, .properties files and many others. It is designed to accept text in the non-ascii format and convert it for use in properties files.
    * U said that as u enter the Japanese characters in ur keyboard the editor saves the characters in the unicode format. Are the characters displayed in their glyphs or as \u????.
    They are saved as ascii characters, not glyphs. For example, I entered MSGothic (MS&#12468;&#12471;&#12483;&#12463;) in japanese using net beans and it looks like this when I use a normal text editor: MS\u30B4\u30B7\u30C3\u30AF
    * Can u give me a list of languages f or which this text editor can be used . Bcoz u had suggested that it can be used for chinese also .
    It should work for any language that your windows/linux system has support for (need the right fonts for a start). My system is native japanese, so I have all the required japanese fonts installed. If you want to use (for example) Chinese on an English system, you'll have to get the fonts and probably you will need to modify the jre/lib/font.properties file.
    * I need more info about a Japanese Computer and keyboard. I think we both are in the same level in this topic I18N . Iam working for I18N project in my company. This is my official mail ID- [email protected] .Can u send me ur mail Id so that we make sure that this forum members are not disturbed by our discussion .
    I don't think it's disturbing anyone. Forums are all about sharing information, and there is a lack of experience of I18N in the broader comminity, I feel. This isn't a busy forum... ;-)
    Don't forget to look for the article written by John O'Conner called 'Displaying Text' I don't have the URL handy but it was posted on this forum recently. It's required reading.

  • Reading values from properties file

    Hi All,
    I am in need of a help from you all.I have a login.jsp which gets username and password as user input and checks in the servlet that if it was admin and admin it will take to index.jsp and if it was other than admin and other users it should take to index1.jsp.For now i am using an if condition to check the values and to dispatch the request.I need to use a properties file for this and need to check by getting the values from the properties file.And also it should check for each entry in properties file and if it finds any matches it should take to the corresponding page.
    Please help me in achieving this.
    Thanks,
    laxmi

    Hi All,
    I am in need of a help from you all.I have a login.jsp which gets username and password as user input and checks in the servlet that if it was admin and admin it will take to index.jsp and if it was other than admin and other users it should take to index1.jsp.For now i am using an if condition to check the values and to dispatch the request.I need to use a properties file for this and need to check by getting the values from the properties file.And also it should check for each entry in properties file and if it finds any matches it should take to the corresponding page.
    Please help me in achieving this.
    Thanks,
    laxmi

Maybe you are looking for