... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

2004-12-07

JBOSS

To configure a JDBC data source for a web application in JBOSS, perform the following steps:

  1. Add a reference to the data source in web.xml:
    <resource-ref>
      <description>My Data Source</description>
      <res-ref-name>jdbc/my-data-source</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>
  2. Map the reference name to a JBOSS-style JNDI name in the vendor-specific data source, jboss-web.xml:
    <resource-ref>
      <res-ref-name>jdbc/my-data-source</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <jndi-name>java:/my-data-source</jndi-name>
    </resource-ref>
  3. Create a data source for the JBOSS-style JNDI name by creating a data source file named my-data-source-ds.xml in the JBOSS deploy directory, containing:
    <datasources>
      <local-tx-datasource>
        <jndi-name>my-data-source</jndi-name>
        <connection-url>jdbc:some url</connection-url>
        <driver-class>some.driver</driver-class>
        <user-name>user</user-name>
        <password>password</password>
        <max-pool-size>20</max-pool-size>
        <min-pool-size>0</min-pool-size>
        <blocking-timeout-millis>5000</blocking-timeout-millis>
        <prepared-statement-cache-size>0</prepared-statement-cache-size>
        <check-valid-connection-sql>select 1</check-valid-connection-sql>
      </local-tx-datasource>
    </datasources>

Blog Archive