Hi,
I am new to Jboss and at this point learning about Jboss and JSF. Currently I am working on a very small JSF application (JSF, Spring) that connects to a database (H2) and then reads and display some information from that database. Everything works fine when I perform JNDI lookup from my code as mentioned below.
private Connection getConnectionUsingJNDI() throws Exception { Properties properties = new Properties(); properties.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.setProperty(InitialContext.PROVIDER_URL, "jnp://localhost:1099"); InitialContext ic = new InitialContext(properties); Connection con = null; if (ic != null) { DataSource ds = (DataSource) ic.lookup("java:/H2DS"); con = ds.getConnection(); } return con; }
<jee:jndi-lookup id="dSource" jndi-name="java:/H2DS" resource-ref="true"/>
<bean id="employDAO" class="dao.EmployDAO"> <property name = "dataSource"> <ref bean="dSource"/> </property> </bean>