users@glassfish.java.net

Where to place the properties file?

From: <glassfish_at_javadesktop.org>
Date: Mon, 22 Oct 2007 13:40:28 PDT

I am use the Netbeans (5.5.1) to do the exercise.

I set some config information into a properties file, such as "db.properties" as below

dbuser=username
dbpass=password

and place it to /web/ folder. In a class, I used code:

        Properties dbprop = new Properties();
        dbprop.load(this.getClass().getResourceAsStream("db.properties"));
   
        StringBuffer dsb = new StringBuffer();
        dsb.append(dbprop.getProperty("dbuser"));
        dsb.append(dbprop.getProperty("dbpass"));

When use the app, it came up error for the line of
        dbprop.load(this.getClass().getResourceAsStream("db.properties"));

Where should the "db.properties: to be placed?
[Message sent by forum member 'kingsz1' (kingsz1)]

http://forums.java.net/jive/thread.jspa?messageID=241568