Managing JBoss Datasources

The JBoss Application Server manages its datasources from inside the $JBOSS/server/<profilename>/deploy directory.

Each datasource is defined as a XML-file named "<somename>Db-ds.xml", for our example pentahoDb-ds.xml

The content of the XML-File looks like that

Oracle Style

<?xml version="1.0" encoding="UTF-8"?>
 <datasources>
   <local-tx-datasource>
    <jndi-name>jdbc/PentahoDS</jndi-name>
    <connection-url>jdbc:oracle:thin:@<HOSTNAME>:<PORT>:<SID></connection-url>
    <driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
    <user-name><USERNAME></user-name>
    <password><PASSWORD></password>
    <max-pool-size>100</max-pool-size>
    <new-connection-sql>select * from DUAL</new-connection-sql>
    <blocking-timeout-millis>200000</blocking-timeout-millis>
        <metadata>
          <type-mapping>Oracle9i</type-mapping>
       </metadata>
   </local-tx-datasource>
 </datasources>

MS SQL Style (using the supplied Microsoft JDBC driver)

<?xml version="1.0" encoding="UTF-8"?>
 <datasources>
   <local-tx-datasource>
    <jndi-name>jdbc/PentahoDS</jndi-name>
    <connection-url>jdbc:sqlserver://<HOSTNAME>:<PORT>;SelectMethod=cursor;databaseName=<DBNAME></connection-url>
    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
    <user-name><USERNAME></user-name>
    <password><PASSWORD></password>
    <max-pool-size>100</max-pool-size>
    <new-connection-sql>select 1</new-connection-sql>
   </local-tx-datasource>
 </datasources>

MySQL Style (using the MySQL JDBC driver)

<?xml version="1.0" encoding="UTF-8"?>
 <datasources>
   <local-tx-datasource>
    <jndi-name>jdbc/PentahoDS</jndi-name>
    <connection-url>jdbc:mysql://<HOSTNAME>/<DBNAME></connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name><USERNAME></user-name>
    <password><PASSWORD></password>
    <max-pool-size>100</max-pool-size>
   </local-tx-datasource>
 </datasources>

As soon as this is done, you can use the datasource from e.g. pentaho.war/META-INF/context.xml which would then be changed to:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/pentaho" docbase="webapps/pentaho/">
    <ResourceLink name="jdbc/Hibernate" global="java:jdbc/PentahoDS" type="javax.sql.DataSource" />
  <ResourceLink name="jdbc/Quartz" global="java:jdbc/PentahoDS" type="javax.sql.DataSource" />
</Context>

See that "jdbc/PentahoDS" matches the "jndi-name" defined inside the Datasource-XML.

For details, have a look at the JBoss reference: http://docs.jboss.org/jbossas/docs/Administration_And_Configuration_Guide/5/html/Configuring_JDBC_DataSources.html