2 Replies Latest reply on Feb 5, 2002 2:47 PM by dlaidlaw

    Use JDBC pool from another JVM?

    dlaidlaw

      JBoss 2.4.4

      I have to integrate another software package with JBoss. I cannot run the integration software from the jame JVM as JBoss, as an MBean or an EJB, therefore I would like to access and use a JDBC pool from a different JVM.

      Sounds easy, right? Just lookup the bound JNDI name and request a connection. Unfortunately the JNDI name is bound under the java: namespace and therefore cannot be accessed from a different JVM.

      As a test I copied the org.jboss.jdbc.JDBCDataSourceLoader MBean and modified it to bind to /jdbc/myPool. It started fine as a JBoss MBean and the /jdbc/myPool name bound to JNDI just fine. I then wrote a test program to access /jdbc/myPool and get a connection. No joy:

      try {
      ctx = new InitialContext(ctxProps);
      Object ref = ctx.lookup("/jdbc/myPool");
      if (ref == null) {
      System.out.println("lookup returned null");
      System.exit(1);
      }
      } catch (NamingException nx) {
      ...
      }

      This always outputs "lookup returned null" which means the object returned from JNDI was null.

      Can anyone explain this?

      I am really just trying to get around copying or writing my own JDBC connection pooling code. I need JBoss for other things anyway, so it sure would be nice to be able to use it to do the JDBC connection pooling for me as well. Both JVM's are running on the same machine, but I can't use the JBoss JVM to run the integration code.

      Thanks all!

        • 1. Re: Use JDBC pool from another JVM?
          davidjencks

          You can't access a pool or connection outside of its own vm.

          You could:

          change your mind and write calls to session beans in jboss

          set up a micro-jboss with only naming and pools (and maybe the tx manager) and run your other app inside it, say starting it with an mbean. (Then you could extend this to be the "application client" stuff ;-))

          start the jboss pooling code "by hand" in your other app -- this is not really very hard, you just create the mbean in code and set its properties, then call start or startService.

          Use someone elses pool. Choices may include Tyrex (apparently used in catalina) and poolman.

          Unless you do (1), you will need xa drivers and (at least) Tyrex to get non jboss and in-jboss work into the same transaction.

          • 2. Re: Use JDBC pool from another JVM?
            dlaidlaw

            Thanks David!

            The best option here (for me) is to write some EJB code. Not a problem. I just wanted to make sure.