6 Replies Latest reply on Oct 30, 2006 6:53 AM by inderjeet

    Configure and use Connection pool of Jboss

    inderjeet

      Hi
      I am new to JBoss. I have seen that JBoos has its own Connection pool implementation. I would like to use it with oracle database. Could someone please let me know that how can we configurethe connection pool and how can we use it in a web application?
      Or if someone can forward me the corresponding link. It would be vey helpful to me.

      Thanks for Help
      Inder Jeet Singh

        • 2. Re: Configure and use Connection pool of Jboss
          inderjeet

          Thanks for your reply........
          one more thing i need to know that how can from my web application I can get a connection of the configured database?

          Regards
          Inder Jeet Singh

          • 3. Re: Configure and use Connection pool of Jboss
            jaikiran

            Assuming that this is your datasource configuration:

            <datasources>
             <local-tx-datasource>
             <jndi-name>MyAppDS</jndi-name>
             <connection-url>jdbc:oracle:thin:@youroraclehost:1521:yoursid</connection-url>
            .....
            
            </datasources>


            Note the jndi-name that you have specified for your datasource. The datasource will be bound to java:/MyAppDS jndi-name(in this example). From your web application, you can do a jndi lookup of this datasource, using the jndi-name that you have specified for the datasource, which will return you a Datasource object. You can then invoke the getConnection() method on the returned object. Something like:

            Context ctx = new InitialContext();
            Datasource ds = ctx.lookup("java:/MyAppDS");
            Connection conn = ds.getConnection();





            • 4. Re: Configure and use Connection pool of Jboss
              inderjeet

              I am done with "Getting connection from the JBoss connection pool". Now I would like to know that, after doing my database processiong, how can i return the connection back to the pool?
              I have seen many example for JBoss connection pooling, but in all of then they have used the conn.close(). But according to me, we should not close the connection, instead we should return the connection back to the pool.
              By closing the connection, we are actually beating the purpose of having a connection pool.
              Am I Wrong? If I am not, then how to give the connection back to the pool?


              Thanks & Regards
              Inder Jeet Singh

              • 5. Re: Configure and use Connection pool of Jboss
                jaikiran

                 

                I have seen many example for JBoss connection pooling, but in all of then they have used the conn.close(). But according to me, we should not close the connection, instead we should return the connection back to the pool.


                The internal implementation of the close() method takes care of returning it to the connection pool(Remember that java.sql.Connection is an interface and when you use connection pooling, the server will implement this interface to take care of returning the connection to the pool). So when you invoke the connection.close() method, you are actually returning the connection back to the pool.



                • 6. Re: Configure and use Connection pool of Jboss
                  inderjeet

                  Oh, is it so..........
                  Then it is fine....
                  Thanks for ur prompt reply........