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:


then you can start-up JBoss passing the parameter database-url with the -D flag. Example: -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:



Related articles available on

How to deploy a DataSource in jboss at application level ?

  Do you need to deploy your DataSource along with your Enterpri

JBoss Datasource HA

This tutorial has been updated for the new release of JBoss Appli

JBoss run out of Connections ?

Have you got No ManagedConnections available error message ? well

How to connect to a DataSource from a remote client?

  If you want to connect to your JBoss Connection Pool from a re

JBoss Datasource configuration

A Datasource is a Java Naming and Directory Interface (JNDI) obje

How do I get the list of Datasources available ?

JBOSS AS 4/5 Users You can use either twiddle: $ que

Follow us on Twitter