3 Replies Latest reply on Sep 21, 2005 9:46 AM by Takeshi Toyohara

    datasource from a gui client

    Luca Stancapiano Apprentice

      hi....I don't succeed to connect to "java://DefaultDS" from a swing client.....this is the code:

      try {
       Properties ps = new Properties();
       ps.load(new FileInputStream("resources/jndi.properties"));
       InitialContext ic = new InitialContext(ps);
       Object ref = ic.lookup("java://DefaultDS");
      
       DataSource dcf = (DataSource) ref;
      
       java.sql.Connection dc = dcf.getConnection();
      
       dc.close();
       } catch (NamingException e) {
       e.printStackTrace();
       }


      this is jndi.properties:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=vitro03:10999


      I have this error when I execute DataSource dcf = (DataSource) ref;:

      Exception in thread "main" java.lang.ClassCastException: org.jnp.interfaces.NamingContext
       at client.Main.main(Main.java:231


      why?