[jboss-user] [JNDI/Naming/Network] - JNDI lookup fails with JBoss4.0.4GA Patch1

msmail315 do-not-reply at jboss.com
Mon Nov 13 20:57:29 EST 2006


Hi,
I'm trying to do a JNDI lookup on the DataSource (MySQL) under java: namespace in my JSP and the lookup fails. I've configured all the files pertinent to creating a new data source. I see the new datasource bound in the JNDIView (but not in the global namespace). 
Here's the code:

<%@ page language="java" %>
<%@ page import="javax.sql.*,javax.naming.*,java.sql.*" %>
<%
InitialContext ctxt = new InitialContext();
DataSource ds = (DataSource) ctxt.lookup("java:/jdbc/MySqlDS");
Connection con = ds.getConnection();
if(con != null) out.println("Connection not null");
else out.println("Connection is null");
%>

I wanted to set the <use-java-context>false</use-java-context>  in the *.ds file but per MySQL its not a good practice for a production environment. How can I circumvent this issue? I want to able to access the data source in a servlet as well as in a POJO.

Thanx for your help.
Mash

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3985672#3985672

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3985672



More information about the jboss-user mailing list