8 Replies Latest reply on Sep 23, 2003 11:27 AM by ryandeacon

    No ManagedConnections Available exception

    John-Luc Bakker Newbie

      Dear all,

      I get this:

      [JDBCCommand] Exception caught executing SQL
      org.jboss.util.NestedSQLException: No ManagedConnections Available!;

      I am performing a load test on my system with JRockit, JBoss3.0.0, Jetty and Hypersonic (versions that came with the JBoss package).

      I have a pentium 550mhz, 384mb, w2k under load of 14 evenly distributed http requests per second. Both client and server sit on the same machine. I am not impressed by the response times I get. That may well be because the project I am testing is not designed for good performance ;-)

      How big is the pool with managed connections? Should/can I increase it?

      Also, I'd like to turn of logging. I have turned all logging off except for LOG statements that occur when executing a finder. What to toggle?

      Best regards,

      John-Luc

        • 1. Re: No ManagedConnections Available exception
          Dietmar Schinnerl Newbie

          Hi,

          > How big is the pool with managed connections?

          The size of the pool can normally defined via a XML file (or correctly speaking via a MBean configuration), this should look something like:

          [...]
          <depends optional-attribute-name="ManagedConnectionPool">
          <!--embedded mbean-->

          0
          50
          5000
          15
          ByContainer


          [...]

          File hsqldb-service.xml should be the one you're searching for. (Located in the deploy directory.)

          > Should/can I increase it?

          If it solves the problem. :-) But maybe you're not closing all opened database connections properly? So you run out of connections?

          Best regards,
          Dietamr

          • 2. Re: No ManagedConnections Available exception
            Ronald Pieterse Newbie

            Could you tell me then how to close the connections? I thought it was done by Jboss itself.
            I still have the same problem, but haven't been able to solve it...

            Ronald

            • 3. Re: No ManagedConnections Available exception
              Ronald Pieterse Newbie

              Hello!

              I think I found a solution: I downloaded the new MySQL JDBCDriver (the new version of MM.MySQL) It's now the official MySQL JDBCDriver and the problem was gone. I also had a XAException that is gone now!

              Hope it helps!

              Ronald

              • 4. Re: No ManagedConnections Available exception
                suitao Newbie

                Hi
                I have this problem too,i use JBoss-3.0.3 with Jetty, and database is MS SQL Server 2000.

                I met this problem when i made a 'stress testing', some threads access a web address almost at the same time.

                i have not get the solution.Any help is appreciative! Thanks a lot!

                daniel

                • 5. Re: No ManagedConnections Available exception
                  bullmccabe Newbie

                  Hi,

                  We are getting a No ManagedConnections Available exception intermittently. We are using jboss 3.0.4, our min pool size is 10 and max pool size is 50. As the problem is intermittent is will be difficult for us to ascertain if installing the new driver has fixed the problem. Can you let me know if the above scenario is similar to what you experienced.

                  Thanks.

                  • 6. Re: No ManagedConnections Available exception
                    bullmccabe Newbie

                    Hi,

                    We are getting a No ManagedConnections Available exception intermittently. We are using jboss 3.0.4, our min pool size is 10 and max pool size is 50. As the problem is intermittent is will be difficult for us to ascertain if installing the new driver has fixed the problem. Can you let me know if the above scenario is similar to what you experienced.

                    Thanks.

                    • 7. Re: No ManagedConnections Available exception
                      Itai Maoz Newbie

                      Hi,

                      I'm too getting this exception with JSQL,

                      Have you found a solutions?

                      Thanks,
                      Iati

                      • 8. Re: No ManagedConnections Available exception
                        ryandeacon Newbie

                        I think that this may be a problem in your code. I was having the exact same problem but managed to fix it in the code. Maybe someone can reply to this because I am no Java expert but I will post some of my code. I actually had to explicitly call a method to call the finalize method in my connection bean because the valueUnbound method was never being invoked. When is that "supposed" to be invoked. I assumed it would be garbage collected as soon as I set the connectionBean = null in the calling method but that was not the case. I know this worked fine in Tomcat with an older JDK so maybe there is a difference in the way that JBoss hadles it but here is the code:

                        public class ConnectionBean implements HttpSessionBindingListener {

                        //Instance variables
                        private Context ctx;
                        private Connection connection;
                        private Statement statement;
                        private DataSource ds;

                        //Constructor which makes the connection
                        public ConnectionBean() {

                        try {
                        ctx = new InitialContext();
                        if(ctx == null ){
                        throw new Exception("No Context");
                        }
                        ds = (DataSource)ctx.lookup("java:jdbc/WCCDB");

                        if (ds != null) {
                        connection = ds.getConnection();

                        if (connection != null) {
                        statement = connection.createStatement();
                        }
                        }
                        }

                        catch (SQLException e) {
                        System.err.println("ConnectionBean: driver not loaded");
                        System.err.println(this.toString() + e);
                        connection = null;
                        }
                        catch(Exception e) {
                        System.err.println(this.toString() + e);
                        e.printStackTrace();
                        }
                        }
                        .......

                        //The following event and method will make sure the connection is returned to the pool
                        public void valueUnbound(HttpSessionBindingEvent event) {
                        try {
                        System.out.println("in valueUnboud");
                        statement.close();
                        connection.close();
                        }
                        catch (SQLException e) {
                        System.err.println(this.toString() + e);
                        }
                        finally {
                        statement = null;
                        connection = null;
                        }
                        }

                        protected void finalize() {
                        try {
                        System.out.println("in finalize");
                        statement.close();
                        connection.close();
                        }
                        catch (SQLException e) {
                        System.err.println(this.toString() + e);
                        }
                        }

                        //I added this method because the connections were not being returned
                        public void release() {
                        finalize();
                        }
                        }

                        //Here is an example of it's use in another class....

                        public boolean deleteData() {
                        String sQuery = "";
                        try{
                        if (id > 0) {
                        sQuery = "DELETE FROM facility WHERE id = " + id;
                        }

                        //Perform the update
                        ConnectionBean cb = new ConnectionBean();
                        if (cb.executeUpdate(sQuery) != 0){
                        cb.release();
                        cb = null;
                        return true;
                        }else{
                        cb.release();
                        cb = null;
                        return false;
                        }
                        }
                        catch (Exception e){
                        System.err.println(this.toString() + e);
                        return false;
                        }
                        }


                        Again, your comments are welcome as I am no pro and would love to learn if I am doing something wrong. Thanks.