1 Reply Latest reply on May 8, 2003 9:20 PM by David Jencks

    DataSource in db2-ds.xml coming up in java: context

    bkbonner Newbie

      Can anyone explain to me why the sample in db2-ds.xml only works with java: prepended to the jboss-web.xml?

      here's my web.xml (snippet):

      <resource-ref>
      JDBC
      <res-ref-name>jdbc/TestSource</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>CONTAINER</res-auth>
      </resource-ref>

      here's my jboss-web.xml:

      <!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN"
      "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
      <jboss-web>
      <resource-ref >
      <res-ref-name>jdbc/TestSource</res-ref-name>
      <jndi-name>java:jdbc/DB2DS</jndi-name> <!-- why is (java:) needed here??? -->
      </resource-ref>
      </jboss-web>


      here's my code snippet:

      Context ctx = new InitialContext();
      Context envctx = (Context)ctx.lookup("java:comp/env");
      DataSource source = (DataSource)envctx.lookup("jdbc/TestSource");


      here's my db2-ds.xml:


      <local-tx-datasource>
      <jndi-name>jdbc/DB2DS</jndi-name>
      <connection-url>jdbc:db2:test</connection-url>
      <driver-class>COM.ibm.db2.jdbc.app.DB2Driver</driver-class>
      <user-name>xyz</user-name>
      pdq
      <min-pool-size>0</min-pool-size>
      </local-tx-datasource>