• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help required...

 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
velli fieldman
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe this will help,
DataSource ds = (DataSource) ctx.lookup("/jdbc/MySqlDS");
instead of
DataSource ds = (DataSource) ctx.lookup("jdbc/MySqlDS");
Grtz,
Velli
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,but it didnt help Still gives the error :
/jdbc not bound Exception
 
Alan Petersen
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well,if i try it from within a JSP page,its working,but not from an EJB
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try
public NamingEnumeration listBindings(Name name)
throws NamingException
To list the bindings under jdbc context. I am not sure this will help you.
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic