1 Reply Latest reply on Feb 26, 2004 12:27 PM by Heiko Rupp

    java.sql.SQLException: Communication link failure.(Connectio

    arhu Newbie

      Hi

      My problem is i created an Entity Bean, that insert records in As/400
      DB2 Database, i deployed this EJB and the deploy is OK, sometimes i execute my application the findAll() method and i obtain the results from the table of my database.

      But another times i execute my application, and i obtain

      java.sql.SQLException: Communication link failure.(Connection reset)

      What Can I do ??


      This is my application code:

      import com.NodosRemoteHome;
      import com.NodosRemote;

      public class PruebaBean {

      public PruebaBean() { }


      public static void main(String args[]) {
      PruebaBean prueba = new PruebaBean();

      prueba.invocarBean();
      }


      public void invocarBean() {
      NodosRemoteHome remoteHomeServ = null;
      NodosRemote peticionSrv = null;
      Object ref = null;
      InitialContext jndiContext = null;
      Hashtable env = new Hashtable(3);
      Collection respServs = null;
      Iterator ite = null;
      String etiquetaServ = "";
      String descServ = "";

      env.put(Context.INITIAL_CONTEXT_FACTORY,
      "org.jnp.interfaces.NamingContextFactory");
      env.put(Context.PROVIDER_URL, "147.15.80.120");
      env.put("java.naming.factory.url.pkgs",
      "org.jboss.naming:org.jnp.interfaces");
      try {
      jndiContext = new InitialContext(env);
      ref = jndiContext.lookup("NodosBean");
      remoteHomeServ = (NodosRemoteHome) PortableRemoteObject.narrow(
      ref, NodosRemoteHome.class);
      respServs = remoteHomeServ.findAll();
      ite = respServs.iterator();
      while (ite.hasNext()) {
      peticionSrv = (NodosRemote) ite.next();
      etiquetaServ = peticionSrv.getIdNodo().trim();
      descServ = peticionSrv.getTipoNodo().trim();
      System.out.println("ID NODO " + etiquetaServ);
      System.out.println("TIPO NODO " + descServ);
      }
      } catch (Exception e) {
      System.out.println("[COM]: Ocurrio un Error al invocar NodosBean: "
      + e);
      }
      }