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

    JNDI Lookup timeout

    peafunk

      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.


        • 1. Re: JNDI Lookup timeout
          jaibarra

          Hi,

          database service is up?

          • 2. Re: JNDI Lookup timeout
            peafunk

            Hi,

            Thanks for getting back to me. Yes the database server is up. Could this have to do with the port? I thought the correct port for database access was 1433 but I've seen some people use 1099.

            • 3. Re: JNDI Lookup timeout
              jaibarra

              Maybe, i'm working with versata-jboss and it use that port (1099) and is defined on file named "VSJNDI.properties" look for somethig like that and maybe you can define in that file the right port

              • 4. Re: JNDI Lookup timeout
                peafunk

                Ah-ha, that got it. I set the port in JNDI.properties and also added the following line to the datasource lookup and got it to work.

                env.put(Context.PROVIDER_URL,"localhost:1099");

                Thanks for your help jaibarra.