Results 1 to 5 of 5
- 07-19-2007, 05:13 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
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
- 07-19-2007, 11:10 PM #2
Member
- Join Date
- Jul 2007
- Posts
- 41
- Rep Power
- 0
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?
- 07-20-2007, 10:20 AM #3
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
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:
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"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%'", 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; }
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,
SilviaLast edited by JavaBean; 07-20-2007 at 10:24 AM. Reason: Code placed inside [code] tag.
- 07-20-2007, 10:23 AM #4
Silvia,
I placed your code inside [code] tags. Please use it next time since it makes your code more readable!
- 08-09-2007, 10:41 PM #5
Member
- Join Date
- Jul 2007
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
Hibernate with multiple database
By Marty in forum JDBCReplies: 3Last Post: 12-23-2008, 12:57 PM -
Using JDBC to connect to ORACLE database
By Java Tip in forum Java TipReplies: 0Last Post: 02-10-2008, 11:27 AM -
How can I store an image to the database using hibernate
By cryss_tyna in forum JDBCReplies: 0Last Post: 08-15-2007, 01:48 PM -
problem with hibernate and oracle 8i
By javadev in forum JDBCReplies: 4Last Post: 08-09-2007, 02:21 PM -
can hibernate work with Oracle 10g
By javadev in forum JDBCReplies: 4Last Post: 07-08-2007, 08:47 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks