6 Replies Latest reply on Jul 30, 2002 2:39 PM by gabrielm

    programatically handle datasources

    gabrielm

      Hi!
      I'm doing a DB-explorer app, and I need a way to programatically add/remove/configure datasources. The users will be selecting the type of the DB, the machine running it, and an account/password combination, and the system will automatically add the DB, and its catalogs and all to a DHTML tree.
      (think of a web version of DBVisualizer).

      I'd rather avoid using JDBCpool or PoolMan, seeing that JBoss has its own wonderful connection pooling mechanism.

      I know about the :8082 interface, but that doesn't helps. I need to do it programatically, with Java code, from a servlet, without a restart, if possible.

      I'm looking forward to buying the JBoss3.0 book, when it will be out, but meanwhile, projects must go on.

      (repost, since the original thread died)

        • 1. Re: programatically handle datasources
          schaefera

          Hi

          A servlet (as long as deployed on the same box) can look up the JMX MBeanServer with the MBeanServerFactory. Then you can manage the JCA Connection MBeans through the JMX MBeanServer factory.

          Hope this helps

          Andy

          • 2. Re: programatically handle datasources
            davidjencks

            Since you mention wanting the 3.0 book, I assume you are using a jboss 3 version. Look in the testsuite in jmx/test/DeployConnectionManagerUnitTestCase to see an example (slightly messy) of creating a datasource deployment via code.

            • 3. Re: programatically handle datasources
              gabrielm

              Where is that? I couldn't find anything in the CVS tree (that thing is HUGE!).
              Should I download the source?

              P.S. sorry about the crosspost.

              • 4. Re: programatically handle datasources
                gabrielm

                org.jboss.test.jmx.test.DeployConnectionManagerUnitTestCase is not in the jboss main source, if that's what I'm looking for.

                • 6. Re: programatically handle datasources
                  gabrielm

                  That class didn't really helped since I can't tell what's JUnit, what's part of JMX, what's JBoss and what's this class's stuff...

                  This is what I have so far:

                  ObjectName cmName = new ObjectName("jboss.jca:service=LocalTxCM,name=TestDS");
                  ObjectName mcfName = new ObjectName("jboss.jca:service=LocalTxDS,name=TestDS");
                  ObjectName mcpName = new ObjectName("jboss.jca:service=LocalTxPool,name=TestDS");
                  ObjectName serviceControllerName = new ObjectName("jboss.system:service=ServiceController");
                  AttributeList al = new AttributeList();
                  al.add(new Attribute("JndiName", "ConnectionManagerTestDS"));
                  al.add(new Attribute("ManagedConnectionFactoryName", mcfName));
                  al.add(new Attribute("ManagedConnectionPool", mcpName));
                  al.add(new Attribute("CachedConnectionManager", new ObjectName("jboss.jca:service=CachedConnectionManager")));
                  al.add(new Attribute("JaasSecurityManagerService", new ObjectName("jboss.security:service=JaasSecurityManager")));
                  al.add(new Attribute("TransactionManager", "java:/TransactionManager"));
                  al.add(new Attribute("MinSize", new Integer(0)));
                  al.add(new Attribute("MaxSize", new Integer(50)));
                  al.add(new Attribute("BlockingTimeoutMillis", new Long(5000)));
                  al.add(new Attribute("IdleTimeoutMinutes", new Integer(15)));
                  al.add(new Attribute("Criteria", "ByContainer"));

                  Is this ok? How do I turn this into a datasource? Will this datasource be saved, and reinitialized after reboot? How can I remove a datasource programatically?

                  I can't wait for the Jboss3 books!!!