-
1. Re: JNDI lookup failure in Custom Login Module
carln9 Sep 10, 2010 6:45 AM (in response to sahidkhn)Hi Sahid
I know this post is a couple of years old, but I am having the same problem. Did you ever find a solution?
I know my datasource is ok, as I created a new war deployedment and the following jsp client worked.
<%@page contentType="text/html"
import="java.util.*,javax.naming.*,javax.sql.DataSource,java.sql.*"
%>
<%DataSource ds = null;
Connection con = null;
PreparedStatement pr = null;
InitialContext ic;
try {
ic = new InitialContext();
ds = (DataSource)ic.lookup( "java:/OracleDB" );
con = ds.getConnection();
pr = con.prepareStatement("SELECT TO_CHAR (SYSDATE, 'DD-MM-YYYY') AS CUR_DATE FROM DUAL");
ResultSet rs = pr.executeQuery();
while (rs.next()) {
out.println("<br> " +rs.getString("CUR_DATE"));
}
rs.close();
pr.close();
}catch(Exception e){
out.println("Exception thrown " +e);
}finally{
if(con != null){
con.close();
}
}
%>Cheers
Carl