9 Replies Latest reply on Feb 3, 2005 5:20 AM by timwebber

    Stateful Session bean and java.sql.Connection problem

    ijaz79

      I am creating java.sql.Connection with Oracle in ejb create in Stateful Session Bean.
      As
      Connection conn;

      ejbCreate(){
      Context ctx = new InitialContext();
      Object obj = ctx.lookup(“java:/OralceDS”);
      if (obj instanceof DataSource) {
      DataSource ds = (DataSource) obj;
      Conn = (Connection) ds.getConnection();
      }

      List getRestult(){
      // Â…Â….
      // Return list
      }

      In client of Stateful session bean as soon as I call the create method . Connection is being closed by server and and following error message is printed on jboss consoles

      [CachedConnectionManager] Closing a connection for you. Please close them yourself: org.jboss.resource.adapter.jdbc.WrappedConnection@e7cb66 java.lang.Exception: STACKTRACE at org.jboss.resource.connectionmanager.CachedConnectionManager.registerConnection(CachedConnectionManager.java:282) at org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:506)
      at org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:814)
      at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:102)

        • 1. Re: DR1 AOP goals
          ter_d

          Bill no need to apollogize for the goals..

          If you read my Rcikard' comments alreqdy you know that there are both logic and data hole sin Rickard's technical points.. :)

          I for one am satisifed with the goals that have been met so far and I am starting to explore how to integrate JBoss with my Mobile game server concepts and achitecture this fall and spring of 2004..

          I look forward to exploring more JBoss AOP that the group defines..

          AOP in the way JBoss is implementing it is important to me on my gameGO proejct becasue in Mobile game serving environments you have to serve the gaem controller on the server side as their is not enough bandwidth/processing power on the handset side ..

          Thus, even using Jini you have serialization of bojects and thus the desire to use every trick in the book to reduce the performanc ehit of that object creation..using AOP in JBOss allows me to address that issue in a new interesting ways that solve the problem..without the added bloat of EJB..

          • 2. Re: Stateful Session bean and java.sql.Connection problem
            cooperbry

            Did you get an answer to this problem? If so, could you share it with me?

            Thanks,
            Bryan Cooper

            • 3. Re: Stateful Session bean and java.sql.Connection problem
              kabirkhan

              You should get the connection from the pool when you need it and not hang onto it. Make sure you close it before returning from a session bean method.

              void mymethod()
              {
               Object obj = (DataSource)ctx.lookup(jndiName);
              Connection conn = (Connection) ds.getConnection();
               try
               {
               //Use conn
               }
               catch(Exception e)
               {
               }
               finally
               {
               conn.close();
               }
              }





              • 4. 3774979
                kabirkhan

                PS also close statements and resultsets in the finally block

                • 5. Re: Stateful Session bean and java.sql.Connection problem
                  ter_d

                  The reply at the beginning of this page is not the one I post one Friday. I would like to know where it is!!!! And who wrote in my name with no permission!

                  • 6. Re: Stateful Session bean and java.sql.Connection problem
                    darranl

                     

                    And who wrote in my name with no permission!


                    There is currently an issue with the forum database where a number of posts have had their original author changed, I think the database is due to be rebuilt soon to correct this.

                    • 7. Re: Stateful Session bean and java.sql.Connection problem
                      ter_d

                      Hi darranl,
                      so... where's my reply with my problem?
                      Esther

                      • 8. Re: Stateful Session bean and java.sql.Connection problem
                        darranl

                         

                        "ter_d" wrote:
                        Hi darranl,
                        so... where's my reply with my problem?
                        Esther


                        Somewhere else within the forums, they are currently trying to fix the problems.

                        • 9. Re: Stateful Session bean and java.sql.Connection problem
                          timwebber

                          Tidying up your connections before exiting the bean is normally the thing to do, but what do you do if the bean is a SFSB and a database connection is part of the state to be kept between successive calls to the bean?

                          Tim