Dear All,
Instead of hardcoding the username and password in the class to get connected to the database ( i am using connection pool) i want to put the properties in external file .
so instead of hardcoding scott and tiger as I have in following code I want to use external properties file to get the username and password:
( please note that I am using weblogic connection pool and want to avoid using
DriverManager.getConnetion(). Instead of that I want to use Driver.connect )
String querysql;
ResultSet rs = null;
try {
java.util.Properties props = new java.util.Properties();
props.put("user", "scott");
props.put("password", "tiger");
java.sql.Driver d = (java.sql.Driver)Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
java.sql.Connection conn = d.connect("jdbc
racle:thin:myhostname", props);
Statement stmt = conn.createStatement();
querysql=" SELECT * FROM EMP"+
"
rs=stmt.executeQuery(querysql);
while(rs.next()) {
..
..
}
if(stmt != null)
stmt.close();
if(conn != null)
conn.close();
}
catch(ClassNotFoundException e) {
}
catch(SQLException e) {
}
catch(Exception e) {
}
Thanks,
smita