1 Reply Latest reply on May 8, 2003 2:09 AM by Jon Barnett

    JBoss 3.2 connecting DS outside JBoss' JVM

    Rahul Shinde Newbie

      How to connect a datasource say MSSQL type outside the JBoss' JVM?

      I have a client (running in its own JVM) that makes the standard call for lookup and getConnection().
      >>>>>>
      InitialContext ctx = new InitialContext();
      DataSource ds (DataSource) ctx.lookup("java:/MSSQLDS");
      Connection dbconn ds.getConnection();
      <<<<<<

      The MSSQLDS is defined using the sample mssql-ds.xml file.

      When the client is run I get an exception.
      >>>>>
      javax.naming.NameNotFoundException: DefaultDS not bound
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:240)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:215)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:117)
      at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
      at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
      at javax.naming.InitialContext.lookup(InitialContext.java:345)
      at com.primus.security.TestCaseJBossMSSQLServerJDBC.testConnectionThruJDBCManager(TestCaseJBossMSSQLServerJDBC.java:63)
      <<<<<

      I read in another post where it is mentioned that datasource cant be accessed from remote clients.
      http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t= that holds true for JBoss 3.2.x, can anyone explain me why is it so? Also if there is any way a remote client can access the datasource without creating a session bean.

      Thanks,
      Rahul

        • 1. Re: JBoss 3.2 connecting DS outside JBoss' JVM
          Jon Barnett Master

          A Java DataSource is a factory for connections to a physical datasource. These physical connections are manifested in the VM that implements the Java datasource representation. The Java representations of these connections cannot be handed to another VM (a remote client) because the remote VM has no physical connection to the physical datasource.

          Your session bean can act as your connection proxy, in so far as it can use the connection on your behalf - the DataSource connection is not a proxy to the underlying physical connection so you cannot directly use it from a remote point.