1 Reply Latest reply on Nov 24, 2003 3:01 AM by Jon Barnett

    Get Datasource from Client side

    kennethchen Newbie

      I can get a Datasource in Server side,but
      I can't get a Datasource in Client side,the exception is javax.naming.NameNotFoundException: URS not bound

      Can anyone point out what else I need to do?
      Why I can get a Datasource in Server side,but
      I can't get a Datasource in Client side?
      Thanks!

      This is the code[Server Side] I have for getting the DataSource:
      try {
      Context ctx;
      ctx = new InitialContext( );
      DataSource ds = (DataSource)ctx.lookup("java:/URS");
      Connection con = ds.getConnection();
      } catch( Exception e ) {
      e.printStackTrace();
      }


      This is the code[Client Side] I have for getting the DataSource:

      try {
      Context ctx;
      Hashtable p=new Hashtable();
      p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL, "localhost:1099");
      ctx = new InitialContext( p );
      DataSource ds = (DataSource)ctx.lookup("java:/URS");
      Connection con = ds.getConnection();
      } catch( Exception e ) {
      e.printStackTrace();
      }

      And this is the msaccess-ds.xml file in the jboss deploy directory:


      <local-tx-datasource>
      <jndi-name>URS</jndi-name>

      <connection-url>jdbc:odbc:URS</connection-url>
      <driver-class>sun.jdbc.odbc.JdbcOdbcDriver</driver-class>
      <user-name></user-name>

      </local-tx-datasource>

        • 1. Re: Get Datasource from Client side
          Jon Barnett Master

          You cannot use a datasource outside the JVM in which the connection pool exists. Since the database connections only physically exist in that JVM and the DataSource issued connections are not a proxy implementation, you cannot perform an external lookup of this resource. You also lose most of the benefits of the connection pool by having to establish a remote connection to the connection pool to obtain the actual connection to the database if this were possible.