Default database connectivity configurations for JBoss Applications

Code: 
KB-E1076
Applies to: 
OpenShift
Issue: 

How do I connect my JBoss application to an embedded database?

Resolution: 

To connect an OpenShift JBoss app to and embedded db, mysql for example, you can use the existing MysqlDS config in your repo's .openshift/config/standalone.xml:

<datasource jndi-name="java:jboss/datasources/MySQLDS" enabled="${mysql.enabled}" use-java-context="true" pool-name="MySQLDS">  
       <connection-url>jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}  /${env.OPENSHIFT_APP_NAME}  
       </connection-url>  
...

There is no need to modify it as it is preconfigured using the $OPENSHIFT_DB* env variables as recommended. You just need to use that DS in your persistence.xml.

A great example can be found here:
https://github.com/openshift/kitchensink-example

The only change needed is to:
https://github.com/openshift/kitchensink-example/blob/master/src/main/resources/META-INF/persistence.xml
from:

         <jta-data-source>java:jboss/datasources/KitchensinkQuickstartDS</jta-data-source>

to:

      <jta-data-source>java:jboss/datasources/MySQLDS</jta-data-source>

Note that no changes are required in:
https://github.com/openshift/kitchensink-example/blob/master/src/main/webapp/WEB-INF/kitchensink-quickstart-ds.xml