Hi All,
I am developing a project whose architecture is something like this :
JSP --> Servlet --> Bean(which interactes with DB)
JSP <-- Servlet <-- Bean(which interactes with DB)
Now ,I am trying to catch any exception and display using error page.
Structure of my Bean :
public Vector getDump(String strTblName, String strColNames, String strConditions) throws SQLException, Exception
{
try
{
-- does something
}
catch (SQLException sqle)
{
throw new SQLException(sqle.getMessage()+" -> Error in taking dump");
}
catch(Exception e)
{
throw new Exception(e.getMessage()+" -> Error in Extraction");
}
Now in My servlet I am trying to rethrow the exception so as to catch itis errorPage.
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
if (task.equals("takeDump"))
{
try
{
vecDump = dbMan.getDump(strTblName,strColNames,strConditions);
---- do some work here
}
catch(IOException ioe)
{
throw new IOException(ioe.getMessage()+" -> Error in IO");
}
catch (SQLException sqle)
{
throw new SQLException(sqle.getMessage()+" -> Error in SQL ");
}
}
}
But in the End I am getting error as :
unreported exception java.lang.Exception; must be caught or declared to be thrown :=>> throw new Exception(sqle.getMessage()+" -> Error in SQL");
Even if I change SQLException to Exception, I am getting the same sort of error.
Please help !!!
Thanks in advance.
Nilesh