4 Replies Latest reply on Sep 26, 2004 8:40 AM by Thierry Janaudy

    How to access a DataSource in JBoss 4.0 from a client?

    nimrod Newbie

      I have deployed the mssql-ds.xml to D:\jboss-4.0.0\server\default\deploy, the mssql-ds.xml is like this:

      <jndi-name>mySqlServerDB</jndi-name>
      <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=test</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>sa</user-name>

      and when the Jboss starting, the console displayed:
      11:56:26,521 INFO [WrapperDataSourceService] Bound connection factory for resource adapter for ConnectionManager 'jboss.jca:
      name=mySqlServerDB,service=DataSourceBinding to JNDI name 'java:mySqlServerDB'


      and my java code is like this:

      DataSource ds = null;
      String dsName = "java:mySqlServerDB";
      try{
      Properties props = new Properties();
      props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      props.setProperty("java.naming.provider.url","jnp://localhost:1099");
      props.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      Context ctx = new InitialContext(props);
      ds = (DataSource) ctx.lookup(dsName);
      ds.getConnection();
      }catch(Exception e){
      e.printStackTrace();
      }

      Running the code, I got this message "javax.naming.NameNotFoundException: myHibernateSqlServerDB not bound", so, why?