PostgreSQL Datasource in JBoss AS7

First add a postgresql module to your modules folder as described in my former post. Then open standalone.xml and insert a datasource and the postgresql driver.

Search for subsystem xmlns=”urn:jboss:domain:datasources:1.0″ and insert the datasource.

<datasource jndi-name="java:jboss/datasources/TestDS"
	pool-name="TESTDS" enabled="true" jta="true" use-java-context="true"
	use-ccm="true">
	<connection-url>
		jdbc:postgresql:test
	</connection-url>
	<driver>
		org.postgresql
	</driver>
	<pool>
		<min-pool-size>
			5
		</min-pool-size>
		<max-pool-size>
			25
		</max-pool-size>
		<prefill>
			false
		</prefill>
		<use-strict-min>
			false
		</use-strict-min>
		<flush-strategy>
			FailingConnectionOnly
		</flush-strategy>
	</pool>
	<security>
		<user-name>
			someuser
		</user-name>
		<password>
			somepass
		</password>
	</security>
	<validation>
		<check-valid-connection-sql>
			SELECT 1
		</check-valid-connection-sql>
		<validate-on-match>
			false
		</validate-on-match>
		<background-validation>
			false
		</background-validation>
		<use-fast-fail>
			false
		</use-fast-fail>
	</validation>
</datasource>

Then insert the driver under the driver section below.

<driver name="org.postgresql" module="org.postgresql">
	<xa-datasource-class>
		org.postgresql.xa.PGXADataSource
	</xa-datasource-class>
</driver>

Leave a Comment