Default database connectivity configurations for JBoss Applications


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


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}  

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:

The only change needed is to:




Note that no changes are required in: