This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Hi, I am trying to connect to Jboss3.2 & Mysql 3 .I have modified the mysql-ds.xml such that it now reads <jndi-name>jdbc/MySqlDS</jndi-name> Have pasted the mysql driver in appropriate places. When I see the web-console i see the jdbc/MySqlDS under jboss.jca. The log file also shows JNDI name bound to 'java:/jdbc/MySqlDS' However when i try to use i from the client as: Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); env.put(Context.PROVIDER_URL, "localhost"); env.put(Context.URL_PKG_PREFIXES, "org.jboss.naming rg.jnp.interfaces" ); Context ctx = new InitialContext(env); System.out.println(ctx); DataSource ds = (DataSource) ctx.lookup("java:/jdbc/MySqlDS"); I get a NameNotBound :jdbc not bound Exception
I also tried this: DataSource ds = (DataSource) ctx.lookup("jdbc/MySqlDS"); Still i get the same exception. Please help. I posted this in the JBoss forum but no one answered
You're doing this within a J2EE component? If so, then you just want to create your Context like this: Context ctx = new InitialContext() Then do your JNDI lookup. Of course, your JNDI lookup should be for a string starting with java:comp/env/ and then you need to define the resource-ref in the deployment descriptor, and the mapping between the ref-name and the JNDI name in the jboss-specific deployment descriptor... - alan
Joined: Jan 27, 2001
Well,if i try it from within a JSP page,its working,but not from an EJB
Hi, Alan about your reply ,cant i run a simple client (normal java class) doing the look up?Do i have to make an ejb from it?Do i have to package the class files in an ear?I think not.The same code works in Weblogic if I change the naming properties from Jboss's to Weblogic. Still