I have defined the data source in struts-config.xml
. I want to get a connection from it in a Struts action class.
The code is:
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
LoginForm loginForm = (LoginForm) form;
Connection con = null;
DataSource ds;
try {
ds = getDataSource(request,"A");
con = ds.getConnection();
} catch (Exception e) {
}
return null;
}
The line
ds = getDataSource(request,"A");
gives the following compilation error:
Type mismatch: cannot convert from DataSource to DataSource
How can this happen and how can I fix this?