Results 1 to 5 of 5
  1. #1
    scastro is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Question Hibernate 2.1.8 / Oracle 10 / Tomcat 5.0.28 : Data not retrieved from the database

    Dear all,
    Here is my problem:

    I was using hibernate 2.1.8 with Oracle 8, and TomCat - Spring for showing data from a db.
    I have changed to Oracle 10, and there are no errors at all, but the data is not retrieved.
    I am using the correct Dialect (Oracle9Dialect) I guess, and the driver for Oracle 10 (ojdbc14-10.2.0.3.0.jar)

    The funny thing is that testing the code without TomCat, gives correct results, but when running it under TomCat, the data is not there (returns null or 0).:confused:

    Any clue in this?
    Thanks in advance,
    Cheers,
    Silvia

  2. #2
    oregon is offline Member
    Join Date
    Jul 2007
    Posts
    41
    Rep Power
    0

    Default

    It's very strange
    It gives to you an error or something like that?
    can you paste the code?
    Did you try to re-install the tomcat?

  3. #3
    scastro is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Default

    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:

    Java 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&#37;'", 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 11:24 AM. Reason: Code placed inside [code] tag.

  4. #4
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    9

    Default

    Silvia,

    I placed your code inside [code] tags. Please use it next time since it makes your code more readable!

  5. #5
    leonard is offline Member
    Join Date
    Jul 2007
    Posts
    43
    Rep Power
    0

    Default

    Did you try uninstall tomcat and reinstall it?
    It sounds silly but It often works

Similar Threads

  1. Hibernate with multiple database
    By Marty in forum JDBC
    Replies: 3
    Last Post: 12-23-2008, 01:57 PM
  2. Using JDBC to connect to ORACLE database
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-10-2008, 12:27 PM
  3. Replies: 0
    Last Post: 08-15-2007, 02:48 PM
  4. problem with hibernate and oracle 8i
    By javadev in forum JDBC
    Replies: 4
    Last Post: 08-09-2007, 03:21 PM
  5. can hibernate work with Oracle 10g
    By javadev in forum JDBC
    Replies: 4
    Last Post: 07-08-2007, 09:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •