4 Replies Latest reply on Apr 24, 2006 10:01 AM by Price Ellington

    JNDI Lookup timeout

    Price Ellington Newbie

      Hi,

      I am trying to get a connection to a datasource but I am getting a communication exception. I'm not sure what the problem is here and I haven't seen any other posts with the same issue. Can someone please point me in the right direction? The exception I get doing a lookup for the datasource is:

      javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]

      We are using MS Sql Server, here is the mssql-ds.xml file:


      <no-tx-datasource>
      <jndi-name>jndiname</jndi-name>
      <use-java-context>false</use-java-context>
      <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=dbname</connection-url>
      <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
      <user-name>XXX</user-name>
      XXX
      </no-tx-datasource>



      And here is the code to lookup the datasource:

      Connection con = null;
      Context ctx = null;
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
      env.put(Context.SECURITY_PRINCIPAL, "XXX");
      env.put(Context.SECURITY_CREDENTIALS, "XXX");

      try{
      ctx = new InitialContext(env);
      javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("jndiname");
      con = ds.getConnection();
      }catch(Exception e) {
      e.printStackTrace();
      }

      Thanks in advance.