HI,
Thanks in advance.please help me to solve this exception.
I am new to JBOSS and spring.I wrote a simple program which gets database connection from connection pool.In lookup I am getting class cast exception saying "Cannot cast javax.naming.Reference to javax.sql.DataSource-Class cast exception".I cannot understand how lookup returns a Reference object. The same thing works well in a JSP page.Here's my code:
public void dispCount() throws NamingException {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099");
Context ctx=new InitialContext(env);
DataSource ds = (DataSource) ctx.lookup("OracleDS");
JdbcTemplate jt = new JdbcTemplate(ds);
int count = jt.queryForInt("select count(*) from emp");
System.out.println("Count: "+count);
}


Reply With Quote