Pour utiliser un datasource déclaré dans le fichier struts-config.xml, par exemple dans une Action, vous devez faire comme ceci:
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
javax.sql.DataSource dataSource;
java.sql.Connection myConnection;
try
{
dataSource = getDataSource(request);
myConnection = dataSource.getConnection();
}
catch (SQLException sqle)
{
...
}
finally
{
try {
myConnection.close();
} catch (SQLException e) {
getServlet().log("Connection.close", e);
}
}
}