facebook

Not able to obtain connection

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #237172 Reply

    pcleung
    Member

    At 1st, Hibernate can retrieve records when “getUserProfileList” is run.
    After addition of record and then “getUserProfileList” is run again.
    The following error messages display.

    Why is it so?

    org.apache.jasper.JasperException: org.hibernate.HibernateException: Not able to obtain connection
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    root cause

    java.lang.RuntimeException: org.hibernate.HibernateException: Not able to obtain connection
    com.erp.hibernate.UserProfileService.getUserProfileList(UserProfileService.java:182)
    org.apache.jsp.user.addUserProfile_jsp._jspService(org.apache.jsp.user.addUserProfile_jsp:120)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

    #237175 Reply

    Riyad Kalla
    Member

    Moving to OT > Soft Dev.

    pcleung, I’d suggest you went over your settings with a fine tooth comb and then asked the folks on forums.hibernate.org, but please provide more detail for them, keep in mind I can’t even begin to answer your question with that you’ve posted.

    #239295 Reply

    thy3368
    Member

    At 1st, Hibernate can retrieve records when “getUser(1, 20)” is run.
    After addition of record and then “getUser(1, 20)” ” is run again.
    The following error messages display.

    org.hibernate.HibernateException: Not able to obtain connection
    at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:113)
    at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:88)
    at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1162)
    at org.hibernate.loader.Loader.doQuery(Loader.java:390)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
    at org.hibernate.loader.Loader.doList(Loader.java:1593)
    at org.hibernate.loader.Loader.list(Loader.java:1577)
    at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
    at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
    at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
    at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
    at com.guoteng.hibernate.SubmitService.getSubmit(SubmitService.java:257)
    at com.guoteng.struts.action.MagsubmitAction.list(MagsubmitAction.java:63)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:696)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:474)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:409)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
    at java.lang.Thread.run(Thread.java:536)
    2005-10-13 12:48:59,386 [org.apache.struts.util.PropertyMessageResources]-[INFO] Initializing, config=’org.apache.struts.taglib.bean.LocalStrings’, returnNull=true

    
        public List getUser(int offset, int count) throws Exception {
            /*
             * Use the ConnectionFactory to retrieve an open Hibernate Session.
             * 
             */
            Session session = null;
    
            try {
                session = MySessionFactory.currentSession();
                /*
                 * Build HQL (Hibernate Query Language) query to retrieve a list of
                 * all the items currently stored by Hibernate.
                 */
                Query query = session
                        .createQuery("select user from com.guoteng.hibernate.User as user");
                return query.list();
    
            } catch (HibernateException e) {
                System.err.println("Hibernate Exception" + e.getMessage());
                throw new RuntimeException(e);
            } finally
    
            {
                if (session != null) {
                    try {
                        session.close();
                    } catch (HibernateException e) {
                        System.err.println("Hibernate Exception" + e.getMessage());
                        throw new RuntimeException(e);
                    }
                }
            }
        }
Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Not able to obtain connection

You must be logged in to post in the forum log in