6 Replies Latest reply on May 23, 2002 9:28 PM by Colin Canfield

    connection pooling in RC2?

    Jeff Brown Newbie

      I am trying to migrate from 3.0.0 to RC2 and see that there are some changes in database connection pooling. I was using ConnectionFactoryLoader in 3.0.0 and was handling transactions within the code itself.

      Would someone give me an example of setting up the db2-service.xml file for the new corresponding connectoin manager I should use in Rc2?

      Note, I did get the sample using LocalTXConnectionManager to work, but I get errors with the autocommit() in my code so I assume I need to use NoTXConnectionManager.

      If this assumption is true, can someone give me a sample of NoTXConnectionManager in a ...-service.xml file.


        • 1. Re: connection pooling in RC2?
          David Jencks Master

          You should be able to use the LocalTxConnectionManager. What are the problems you are experiencing with autocommit? Do they occur with other dbs such as hypersonic? Please try to supply enough information so I have a reasonable chance of figuring out what is wrong.

          • 2. Re: connection pooling in RC2?
            Jeff Brown Newbie

            Thanks, I can get it to work with the LocalTX as you said. I have each session bean set up with NoTransaction in the ejb-xml file.

            I did have to comment out some of the autocommit(true) statements in my code though; otherwise I was getting an SQLException = sql is not valid. Not sure why, but still need to look into it further to ensure my ejb.xml file is configured correctly.

            BTW, what/when should the NoTXConnectionManager be used?

            • 3. Re: connection pooling in RC2?
              David Jencks Master

              You should use the NoTxConnectinManager if your resource adapter doesn't support any sort of transactions.

              The Local wrapper should get your connections into autocommit mode if you use them outside a managed transaction and don't call setAutoCommit(false) on them. Calling setAutoCommit(anything) inside a managed tx should raise an exception. I wouldn't expect calling setAutocommit(true) outside a managed tx to cause any problems.

              • 4. Re: connection pooling in RC2?
                Colin Canfield Newbie

                If no transaction is specified will connection pooling still work or is this tied to the connection manager ?

                I am doing this from a servlet rather than a bean but I'm assuming if I specify it in the web.xml (or jboss-web.xml ?) the same rules should apply ?

                Thanks ,Colin

                • 5. Re: connection pooling in RC2?
                  David Jencks Master

                  Connection pooling should work even without a managed transaction. The connection should have autocommit true by default (unless you set it differently) outside a managed transaction. If you are using UserTransaction you should not need to ever set autocommit to anything.

                  That being said, I don't think I have any tests for the local wrapper/cm outside managed transactions. So if there are problems please let me know, the ideal way to let me know being with a junit test case ready to go in the test suite;-)

                  • 6. Re: connection pooling in RC2?
                    Colin Canfield Newbie

                    When I tried to deploy with a notx manager it doesn't get completely deployed.

                    The notxds section of the mbean gives a warning that is does not implement any service methods;
                    lookups to the jndi don't find anything (and nothing is in the jndi viewer). ie. the bind is failing.
                    The bind however works with a connection manager enabled service, although I can't use it as from a web servlet;
                    it seems that nothing starts the two phase transaction when used in a web servlet. Can this transaction be manually
                    started ? (a user transaction begin does not seem to do it).

                    I've based my service file off one you put on a list, will this work on RC2 or does it need the CVS version ? I've
                    included the service file just in case there is something really obvious in it.

                    Once I can get it to deploy happily I'll write some test cases for it :)

                    Thanks, Colin

                    <?xml version="1.0" encoding="UTF-8"?>

                    <!--make the rar deploy! hack till better deployment-->
                    <depends optional-attribute-name="ManagedConnectionFactoryName">
                    <!--embedded mbean-->

                    <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=Minerva JDBC LocalTransaction ResourceAdapter
                    <!--real attributes-->



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

                    <!--criteria indicates if Subject (from security domain) or app supplied
                    parameters (such as from getConnection(user, pw)) are used to distinguish
                    connections in the pool. Choices are
                    ByContainerAndApplication (use both),
                    ByContainer (use Subject),
                    ByApplication (use app supplied params only),
                    ByNothing (all connections are equivalent, usually if adapter supports

                    <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager
                    <!-- attribute name="SecurityDomainJndiName">java:/jaas/DefaultDbRealm</attribute -->