Hi to everyone,
i am having following problem.please help me out.
I am retrieving context-param values in contextInitialized() method.
Those values are : databaseUrl(bdUrl), database driver, userName, passWord
Then created one Connection instance named "con".
My question is : Will the connection "con" be alive for all the resources in the corresponding web application.
The code for the contextInitialized given below:
private ServletContext context = null;
Connection con = null;
public void contextInitialized(ServletContextEvent sce){
this.context = sce.getServletContext();
String driver = context.getInitParameter("driver");
String url = context.getInitParameter("dbUrl");
String user = context.getInitParameter("login");
String pass = context.getInitParameter("password");
try{
//Class.forName("org.gjt.mm.mysql.Driver");
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url, user, pass);
}catch(Exception ex)
{
System.out.println("Error in connection :"+ex.toString());
}
}
[ February 07, 2007: Message edited by: Bear Bibeault ]