Ritu Kama wrote:
>
> Hi all,
>
> My requirement is as follows:
>
> I have a initialization file containing the database name.
> Thru my bean I want to read the DB name and establish connection with that
> particular database. I don't want to hardcode the db name.
>
> Please suggest how to achieve this.
>
have a servlet that reads the configfile at servletengine startup
(specified in web.xml for tomcat), have that servlet read the config
variables into public static variables
eg:
class ConfigServlet {
public static String dbDriver;
public static String dbName;
init () {
read variables from configfile
}
class TheBean {
Class.forName(ConfigServlet.dbDriver);
Connection con =
DriverManager.getConnection(ConfigServlet.dbName,"", "");
and so on...
}
this is how i did it, comments are welcome
//peter
--
/**
* peter sönnergren consultant
* i n t e r b i z z s c a n d i n a v i a a b
* http://www.interbizz.com
*/
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets