Author
how to call property file ?
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
Hi All, Anybody please tell me how to call property file in util classes ? I have a util class where I have defined the query as : pstmt = con.prepareStatement("select password from registration where username='"+username+"'"); And I want to use property file instead of writing query in this utility class please help. Thanks
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
Moved to Java in General (intermediate).
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
Raymond Villeno
Ranch Hand
Joined: Jun 21, 2005
Posts: 63
Well first ou must create a FileInputStream Object then load it to a Properties Object. Ex. Something like that... Cheers!
"Work Smart Not Hard"
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
Thanks for your response. So this will be done in util class. ? I am not still clear how to do that. Or how to call querysql.property file in util class ? Please answer with code ? Thanks Harish pathak
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
Thanks for your response. Well I have placed "querysql.property" file inside "C:\orion\default-web-app" and I am retrieving the file as : FileInputStream fis = new FileInputStream ("querysql.property"); Properties dbProp = new Properties(); dbProp.load(fis); pstmt = con.prepareStatement(dbProp.getProperty("password.query")); But it gives me the following error: Exception: verifyPassword=java.io.FileNotFoundException: \querysql.property (The system cannot find the file specified) I don't know where I am wrong. Please reply. Thanks harish pathak
harish pathak
Ranch Hand
Joined: Dec 17, 2005
Posts: 51
Also can we use ResourceBundle to call property file. What is the use of Locale ? Please explain. Thanks harish pathak
Jeff Albertson
Ranch Hand
Joined: Sep 16, 2005
Posts: 1780
posted Feb 24, 2006 05:04:00
0
Originally posted by harish pathak:
Also can we use
ResourceBundle to call property file.
What is the use of Locale ?
http://java.sun.com/docs/books/tutorial/i18n/resbundle/index.html
There is no emoticon for what I am feeling!
Vinayak patil
Ranch Hand
Joined: Aug 30, 2005
Posts: 67
Hi, Is "C:\orion\default-web-app" the root of your project? The program will try to get the file from the root directory of your project and if it does not find it then it throws a FileNotFoundException -Vinayak
"I can resist everything except temptation"
subject: how to call property file ?