View Single Post
  #3 (permalink)  
Old 07-20-2007, 12:20 PM
scastro scastro is offline
Member
 
Join Date: Jul 2007
Posts: 2
scastro is on a distinguished road
Dear Oregon,
Thanks for your reply.

I haven't reinstall Tomcat, because it didn't work in operations environment, so I installed it in my machine, in order to investigate. Tomcat is ok.

Here is the code:

1. The java code:

Code:
public class CurrentPropController extends MultiActionRevolutionController { //private static final Log log = LogFactory.getLog(CurrentPropController.class.getName()); /** Retrieves the current proposals * @param request * @param response * @return Model and view * @throws ServletException */ public ModelAndView currentProp(HttpServletRequest request, HttpServletResponse response) { Session session = getSession(); // Get the AO parameter from the request, default to AO1 if the parameter is invalid String ao = "5"; try { Integer.parseInt(request.getParameter("ao")); ao = request.getParameter("ao"); logger.info("ao parameter: '" + request.getParameter("ao") + "'"); } catch (NumberFormatException e) { logger.warn("Invalid ao parameter: '" + request.getParameter("ao") + "'"); } try { // Load the proposal Map model = BaseAbstractProposalDAO.getInstance().proposalCount(ao, session); logger.info("map created with proposalCount openTime: '" + model.get("openTime") + "'"); // Create a model and return it together with the view name return new ModelAndView("currentPropView","model", model); } catch (ObjectNotFoundException e) { logger.warn("Object Not Found: '" + request.getParameter("ao") + "'", e); return createExceptionModelAndView(e, "AO '" + ao + "' could not be found"); } catch (HibernateException e) { logger.warn("HibernateException: '" + request.getParameter("ao") + "'", e); return createExceptionModelAndView(e, "Unexpected error while loading proposal '" + ao + "'"); } } } public class AbstractProposalDAO extends BaseAbstractProposalDAO { /** * Executes the counting query: * <pre><code> * "SELECT count(p.id) from prop p where "+ whereClause * </code></pre> * using Session s and returns the retreived count as an integer * @param whereClause * @param s * @return * @throws HibernateException */ public Integer proposalCountForCondition(String whereClause, Session s) throws HibernateException { List l = find("select count(p.id) from " + AbstractProposal.class.getName() + " p" +" where "+ whereClause, s); Integer openTime = null; if (l!=null && l.size() == 1) { openTime = (Integer)l.get(0); } return openTime; } /** * Constructing a map with AO statistics, keys are * openTime, keyProgrammes, subscriptionsTotal and the Key Programme * IDs ('0531000' maps to the number of subscriptions to that KP). * * @param AO * @param s * @return * @throws HibernateException */ public Map proposalCount(String AO, Session s) throws HibernateException { Integer openTime = proposalCountForCondition("p.id like '"+AO+"2%'", s); Integer subscriptions = proposalCountForCondition("p.id like '"+AO+"3%' and not(p.id like '%000')", s); Integer keyProgrammes = proposalCountForCondition("p.id like '"+AO+"3_000'", s); Map map = new HashMap(); map.put("openTime", openTime); map.put("subscriptionsTotal", subscriptions); map.put("keyProgrammes", keyProgrammes); for (int k=0; k < keyProgrammes.intValue(); k++) { Integer toThisKP = proposalCountForCondition("p.id like '"+AO+"3"+k+"%' and not(p.id like '%000')", s); map.put(AO+"3"+k+"000", toThisKP); } return map; }
This code is ok when running it as a test unit, (without tomcat), because I can see the trace: "map created with proposalCount openTime: '99"

But when running it with Tomcat, the log is "map created with proposalCount openTime: 0"

If I use, another db (oracle 8) then is working again.
????

Thanks again,
Silvia

Last edited by JavaBean : 07-20-2007 at 12:24 PM. Reason: Code placed inside [code] tag.
Reply With Quote