Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection Error

Status
Not open for further replies.

rmarkert

IS-IT--Management
May 2, 2001
11
BR
How can I catch an error from a Connection failed?

This is my code...

public void init(ServletConfig conf) throws ServletException {

super.init(conf);

try{
String driver = (String)getServletContext().getAttribute("db_driver");
String user = (String)getServletContext().getAttribute("db_adara_user");
String pwd = (String)getServletContext().getAttribute("db_adara_pwd");
String dbstring = (String)getServletContext().getAttribute("db_adara_string");


Class.forName(driver);
con = DriverManager.getConnection(dbstring,user,pwd);


}catch(Exception e) {
What can I do here?
I wanna give a message to user "Connection failed".
}
}



Thanks!

Renata Prates Markert
 
You can't give a message to a user in the init() method. This is called by the Web Container before the first request for the Servlet (usually upon booting the Web Container). Thus the best you can do is write to a log that the servlet could not be initialized and throw a javax.servlet.UnavailableException exception to let the container know that the Servlet failed to be initialized and should not be placed into service.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top