Hi,I wish to make a configuration file for db connection parameters.
I read about properties file.I have made a properties file that contains the following info---

String jdbcDriver="oracle.jdbc.driver.OracleDriver";
String connectionURLThin="jdbc:oracle:thin:@ hostname:AIPUAT1";
String DbUserId="abc";
String DbUserpassword="abc";

and saved it as DbConnection.properties.

i have also made a java file that uses these properties as---

try {

props.load(new FileInputStream("dbConnection.properties"));







catch(Exception e){


public static void main(String[] args)
throws java.lang.InterruptedException {

DbConfiguration dbc = new DbConfiguration();



i am developing a web based application using java and jsp.I have placed my files in webapps folder.Where should i put properties file?.. wt else needs tp be put in the java code?..and how should i lonk this so that other java files can make use of properties(even after being changed).

Edited 3 Years Ago by happygeek: fixed formatting

Put it wherever you want, as long as you say in your code where is it so you can read it:
props.load(new FileInputStream("dbConnection.properties"));
When you make changes in your .properties files, you must restart the server

ok thx..i put it directle in C: drive but when i give
props.load(new FileInputStream("C:\dbConnection.properties"));

im gettin compile time error --illegal escape character '\'...

i used this properties file in my old java file.it takes value from properties file but is giving classNotFoundException..However when i use same driver ,url etc directly in the java class itself and not thru prop,it runs perfectly fine.i have set classpath etc too..what cud be wrong ere?..

maybe your application is not expecting to find what you want it to find :)
mistakes are common you know, is pretty hard though, to try and figure out what the problem is, without having a look at the code that produces the actual Exception

i found the error..had put driver etc names in the properties file under quotes..which is not required..

may it be her problem, she shares the sollution with the rest of the community
This question has already been answered. Start a new discussion instead.