R
robert walker
hi all,
to my webapp named mrf, i have added load-on-startup tag
to mrf\WEB-INF\web.xml
so i added a snippet like so
<servlet>
<servlet-name>loadDbProperties</servlet-name>
<servlet-class>mrf.LoadDbPropertiesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
this servlet just initalizes a connecion pool
*********************************
public class LoadDbPropertiesServlet extends HttpServlet {
public static Properties dbProperties;
public void init() throws ServletException
{
ConnectionPool connPool =
(ConnectionPool)getServletContext().
getAttribute("CONNECTION_POOL");
if (connPool==null)
{
ServletContext sc =
getServletConfig().getServletContext();
try {
dbProperties.load(sc.getResourceAsStream("/WEB-INF/properties/db.properties"));
connPool =
new ConnectionPool((String)dbProperties.get("dbdriver"),
(String)dbProperties.get("dburl"),
(String)dbProperties.get("user"),
(String)dbProperties.get"password"),
Integer.parseInt((String)dbProperties.get("initconns")),
Integer.parseInt((String)dbProperties.get("maxconns")),
true);
getServletContext().setAttribute("CONNECTION_POOL",connPool);
}catch(Exception ioe){ioe.printStackTrace();}
}
}
}
*******************************************
(also tried to put it in tomcat\conf\web.xml but still it does not
load on startup)
why the heck does this not load on startup? i looked for messages on
the groups but still unsure what i am doing wrong
thaks for any insight
to my webapp named mrf, i have added load-on-startup tag
to mrf\WEB-INF\web.xml
so i added a snippet like so
<servlet>
<servlet-name>loadDbProperties</servlet-name>
<servlet-class>mrf.LoadDbPropertiesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
this servlet just initalizes a connecion pool
*********************************
public class LoadDbPropertiesServlet extends HttpServlet {
public static Properties dbProperties;
public void init() throws ServletException
{
ConnectionPool connPool =
(ConnectionPool)getServletContext().
getAttribute("CONNECTION_POOL");
if (connPool==null)
{
ServletContext sc =
getServletConfig().getServletContext();
try {
dbProperties.load(sc.getResourceAsStream("/WEB-INF/properties/db.properties"));
connPool =
new ConnectionPool((String)dbProperties.get("dbdriver"),
(String)dbProperties.get("dburl"),
(String)dbProperties.get("user"),
(String)dbProperties.get"password"),
Integer.parseInt((String)dbProperties.get("initconns")),
Integer.parseInt((String)dbProperties.get("maxconns")),
true);
getServletContext().setAttribute("CONNECTION_POOL",connPool);
}catch(Exception ioe){ioe.printStackTrace();}
}
}
}
*******************************************
(also tried to put it in tomcat\conf\web.xml but still it does not
load on startup)
why the heck does this not load on startup? i looked for messages on
the groups but still unsure what i am doing wrong
thaks for any insight