1 Reply Latest reply on Oct 2, 2004 8:59 PM by shacka

    problem of getting more than 1 connection from DB

    shacka

      WinXP Pro / Jboss 3.2.5 / MySQL 4.0 / JDK1.4

      Hi, all..

      As I was preparing for the upcoming release of my application, I just
      have noticed that there is only one "ACTIVE" connection to DB and
      every client connection is sharing this single connection..

      I can see 5 connections got created when application is deployed but only
      one of the connection is in use when I ran load-test from 4 different
      workstations..

      Here are the snippets of the relavant (I think) files..


      mysql-ds.xml

      <datasources>
       <local-tx-datasource>
       <jndi-name>DefaultDS</jndi-name>
       <connection-url>jdbc:mysql://localhost:3306/dbname</connection-url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <user-name>username</user-name>
       <password>password</password>
       <min-pool-size>5</min-pool-size>
       <max-pool-size>30</max-pool-size>
       </local-tx-datasource>
      </datasources>
      



      standardjbosscmp-jdbc.xml
      <jbosscmp-jdbc>
       <defaults>
       <datasource>java:/DefaultDS</datasource>
       <datasource-mapping>mySQL</datasource-mapping>
      



      ejb-jar.xml
      <resource-ref>
       <res-ref-name>DefaultDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>
      



      from codes
      Context jndiContext = new InitialContext();
      DataSource ds = (DataSource) jndiContext.lookup("java:/DefaultDS");
      




      Is there any other configuration that I am supposed to twick to get multiple connection to MySQL or use ConnectionFactory,
      ConnectionManager, etc..?

      The application runs fine and everything, of course..

      In my setting, I have used "DefaultDS" for minimal changes from
      out-of-box jboss configuration..

      Please shine some insight on this problem..

      Thanks..

      PS: oh btw, JBoss rocks..!!!





        • 1. Re: problem of getting more than 1 connection from DB
          shacka

          Actually, my initial description is wrong..

          I have seen more than one connections utilized when CMP generated
          queries are executed (such as finder method calls)..

          However, the direct jdbc calls within my session beans do use one
          particular connection even if the same call was made by many other
          clients..

          I am lost and I don't know if it is datasource config or jndi config or
          lookup & my code problem..

          Any suggestion would be greatly appriciated

          Thanks..