Reading database connection info from property file

Hii All,

I'm involved in developping j2ee application using MySQL database.

I have hardcoded the database connection settings such as jdbc driver, url, etc during the development time.

Now I need to seperate databse settings from the source code. I haven't done this before. So what I did was specify those information in a property file. (I;m not sure whether it's the most suitable way to do it.) But I have no idea how to read this information back to the code. Can anybody help me to solve this?

Any suggestions would be appreciated.

[573 byte] By [ibmnewa] at [2008-2-16]
# 1

Hello,

Please find the code to do this.

The only expectation is that the Property file "filename.properties" should be there in the class path under the package

com/package1/package2

PropertyResourceBundle myprops = (PropertyResourceBundle) PropertyResourceBundle.getBundle("com.package1.package2.filename");

String JDBCURL = myprops.getString ("JDBCURL");

Hope this helps you.

Thanks and regards,

Pazhanikanthan. P

pazhanikanthana at 2007-7-16 > top of java,Enterprise & Remote Computing,AVK Portability...