How to avoid hardcoding Connection details in the datasource file?

jboss recipe of the day

If you don’t want to hardcode the Connection details of your Datasource in the -ds.xml file, then you can just specify the Connection as a property:

<connection-url>${database.url}</connection-url>

then you can start-up JBoss passing the parameter database-url with the -D flag. Example:

run.sh -Ddatabase.url=jdbc:mysql://localhost:3306/myschema

You can even set up an additional Connection URL which will be used in case the first one (parameterized) will fail:

<connection-url>${database.url:jdbc:mysql://localhost:3306/myschema}</connection-url>