2 big problems: 1. look up java:/DefaultDS
2. you can only access the java: namespace in the jboss vm, without looping through the os. If you are in the jboss vm, just do new InitialContext(). If not, give up, you can't access a DataSource from there. david jencks On 2002.07.11 04:02:16 -0400 Allan Kamau wrote: > I am trying to obtain a connection from the DefaultDS, > but I get the error "DefaultDS not Bound". > Below is the code I use to try a bind to the > DefaultDS. > > <code> > private Connection getConnection()throws SQLException > { > try > { > > Context jndiCntx=getInitialContext(); > Object ref=jndiCntx.lookup("DefaultDS"); > DataSource > ds=(DataSource)javax.rmi.PortableRemoteObject.narrow(ref,DataSource.class); > > > > return ds.getConnection(); > } > catch(NamingException ne) > { > throw new EJBException(ne); > } > } > public static Context getInitialContext() > throws javax.naming.NamingException { > > java.util.Properties env=new java.util.Properties(); > > >env.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); > > env.setProperty("java.naming.provider.url","localhost:1099"); > > >env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces"); > InitialContext initialContext = new > InitialContext(env); > return initialContext; > } > </code> > Thanks. > > > > __________________________________________________ > Do You Yahoo!? > Sign up for SBC Yahoo! Dial - First Month Free > http://sbc.yahoo.com > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > PC Mods, Computing goodies, cases & more > http://thinkgeek.com/sf > _______________________________________________ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek PC Mods, Computing goodies, cases & more http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user