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"));
jdbcDriver=props.getProperty("jdbcDriver");
System.out.println(jdbcDriver);
connectionURLThin=props.getProperty("connectionURLThin");
System.out.println(connectionURLThin);
DbUserId=props.getProperty("DbUserId");
System.out.println(DbUserId);
DbUserpassword=props.getProperty("DbUserpassword");
System.out.println(DbUserpassword);
Class.forName(jdbcDriver);
con=DriverManager.getConnection(connectionURLThin,DbUserId,DbUserpassword);
}
catch(Exception e){
e.printStackTrace();
}
}
public static void main(String[] args)
throws java.lang.InterruptedException {
DbConfiguration dbc = new DbConfiguration();
dbc.classForName();
}
}
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).