Setting up Data source in Wildfly

/bin/jbosscli.sh

Add postgres library

module add –name=org.postgres –resources=/home/inventory/postgresql-9.4-1206-jdbc41.jar –dependencies=javax.api,javax.transaction.api

add subsystem.

/subsystem=datasources/jdbc-driver=postgres:add(driver-name=”postgres”,driver-module-name=”org.postgres”,driver-class-name=org.postgresql.Driver)

/subsystem=datasources:installed-drivers-list

/subsystem=datasources/jdbc-driver=postgres:add(driver-name=”postgres”,driver-module-name=”org.postgres”,driver-class-name=org.postgresql.Driver)

data-source add \
–name=mydatabaseDS \
–jndi-name=java:/mydatabaseDS \
–use-java-context=true \
–use-ccm=true \
–connection-url=jdbc:postgresql://${postgresql.db.host}:${postgresql.db.port}/${postgresql.db.name} \
–driver-name=postgresql \
–user-name=${postgresql.db.username} \
–password=${postgresql.db.password} \
–check-valid-connection-sql=”SELECT 1″ \
–background-validation=true \
–background-validation-millis=60000 \
–flush-strategy=IdleConnections \
–min-pool-size=10 \
–max-pool-size=50 \
—pool-prefill=false

data-source add \
–name=inventoryDS \
–jndi-name=java:/inventoryDS \
–use-java-context=true \
–use-ccm=true \
–connection-url=jdbc:postgresql://localhost/postgres \
–driver-name=postgres \
–user-name=postgres \
–password=123456 \
–check-valid-connection-sql=”SELECT 1″ \
–background-validation=true \
–background-validation-millis=60000 \
–flush-strategy=IdleConnections \
–min-pool-size=10 \
–max-pool-size=50 \
—pool-prefill=false

References

  1. https://docs.jboss.org/author/display/WFLY10/Security+Realms