abyinsydney
Programmer
Greetings fellow citizens
Can any one be kind enough to address my query.I 'm reading from my properties file below
Line no1 //String propFile = "\\..\\JRun\\servers\\default\\archiving\\writeprop.properties";
Line 2 String propFile = "writeprop.properties";
Line 3 //String propFile = "\\..\\..\\servers\\default\\archiving\\writeprop.properties";
System.out.println("we are here in this directory "+propFile);
FileInputStream inputfile;
inputfile = new FileInputStream(propFile);
Properties properties = new Properties();
properties.load(inputfile);
String dns=properties.getProperty("dns");
String value=properties.getProperty("value");
String dbusername=properties.getProperty("username");
String dbpassword=properties.getProperty("password");
System.out.println("Value for dns is "+dns);
System.out.println("Value for value is "+value);
//dns=propsettings.getProperty("email");
System.out.println(dns);
//value= "168.217.20.68";
Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql://"+value+"/"+dns+"";
conn = DriverManager.getConnection (url,dbusername,dbpassword);
Statement stat=conn.createStatement();
My application works fine when i use line number 1 cause that is hard coded but when
i use line two i get an error . Exception3: java.io.FileNotFoundException: writeprop.properties (
The system cannot find the file specified)
I've added the path to writeprop in the class path hnd exessingit
Can any body please let me know the right menthod to read from the properties file .I can read fro mthe file using line 1
but i would like to make it generic
please help
aby
Can any one be kind enough to address my query.I 'm reading from my properties file below
Line no1 //String propFile = "\\..\\JRun\\servers\\default\\archiving\\writeprop.properties";
Line 2 String propFile = "writeprop.properties";
Line 3 //String propFile = "\\..\\..\\servers\\default\\archiving\\writeprop.properties";
System.out.println("we are here in this directory "+propFile);
FileInputStream inputfile;
inputfile = new FileInputStream(propFile);
Properties properties = new Properties();
properties.load(inputfile);
String dns=properties.getProperty("dns");
String value=properties.getProperty("value");
String dbusername=properties.getProperty("username");
String dbpassword=properties.getProperty("password");
System.out.println("Value for dns is "+dns);
System.out.println("Value for value is "+value);
//dns=propsettings.getProperty("email");
System.out.println(dns);
//value= "168.217.20.68";
Class.forName("org.gjt.mm.mysql.Driver");
String url="jdbc:mysql://"+value+"/"+dns+"";
conn = DriverManager.getConnection (url,dbusername,dbpassword);
Statement stat=conn.createStatement();
My application works fine when i use line number 1 cause that is hard coded but when
i use line two i get an error . Exception3: java.io.FileNotFoundException: writeprop.properties (
The system cannot find the file specified)
I've added the path to writeprop in the class path hnd exessingit
Can any body please let me know the right menthod to read from the properties file .I can read fro mthe file using line 1
but i would like to make it generic
please help
aby