1 Reply Latest reply on Jun 16, 2003 11:56 AM by jfradkin

    jndi MSSQL javax.naming.NoInitialContextException: Need to s

    jfradkin Newbie

      I am trying to get set up using MSSQL and Jboss working.

      I have it working with
      Class.forName(driver);
      Connection con1 = DriverManager.getConnection(url, username, password);
      Statement stmt = con1.createStatement();

      but can not get it to work with
      Context ctx = new InitialContext();
      DataSource ds = (DataSource)ctx.lookup("java:/MSSQLDS");
      con = ds.getConnection();

      I keep getting javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

      Help

      including my mssql-ds.xml

      Thanks in advance

      Joel

        • 1. Re: jndi MSSQL javax.naming.NoInitialContextException: Need
          jfradkin Newbie

          I answered my own question after a weekend of reading and punding this until it submitted.

          Easy answer was I did not include the library components from client so jndi was not going to work at all.

          I ended up with
          Context ctx = new InitialContext();
          DataSource ds = (DataSource)ctx.lookup("java:/Drive");
          con = ds.getConnection();

          Once I had the client jars added.

          I also used

          <local-tx-datasource>
          <jndi-name>Drive</jndi-name>
          <connection-url>jdbc:microsoft:sqlserver://192.168.123.110:1433;DatabaseName=wazagua;SelectMethod=cursor</connection-url>
          <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
          <min-pool-size>10</min-pool-size>
          <max-pool-size>100</max-pool-size>
          <user-name>user</user-name>
          pass
          </local-tx-datasource>


          for my mssql-ds.xml

          Initially I was getting the not bound error, but I copied the mssql-ds.xml verbatim from an example on this forum and it works great, Note I still have it named drive, boy am I lazy.

          Hope this helps any other newb's