4 Replies Latest reply on Jun 22, 2010 10:29 AM by Jithu mada

    Looking up datasource defined in Jboss

    Jithu mada Newbie



      I need to lookup a datasource defined in Jboss from a standalone Java program. Both are running on the same machine. This is the code I am using to lookup,but I a getting NameNotFoundException. Can anyone please tell if there is anything incorrect in the code. The Jboss version is 5.1.0 GA and Java version is 1.6.0 and the OS is AIX 6.1.



      Properties properties = new Properties();
      properties.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY ,"org.jnp.interfaces.NamingContextFactory");
      InitialContext ic = new InitialContext(properties);
      DataSource ds = (DataSource)ic.lookup("DB2DS");
      con = ds.getConnection();



      db2-ds.xml file in Jboss















      sql to call when connection is created <new-connection-sql>some

      arbitrary sql</new-connection-sql>




      sql to call on an existing pooled connection when it is obtained from

      pool <check-valid-connection-sql>some arbitrary




      <set-tx-query-timeout />



      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->









      Any replies greatly appreciated.