Skip to content

Postgresql Database Configuration

Jeff Yu edited this page May 5, 2013 · 1 revision

This page illustrates the steps if you want to switch the database to Postgresql. (It is using the h2 in-memory database by default)

Adding the postgresql driver module

  • Creating the org/postgresql/main folder in the $JBossAS/moudles/.

  • Putting the postgresql driver jar in the $JBossAS/modules/org/postgresql/main, like postgresql-9.1-902.jdbc4.jar.

  • Creating a module.xml along with it, the content is as following:

<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
   <resources>
     <resource-root path="postgresql-9.1-902.jdbc4.jar"/>
   </resources>
   <dependencies>
     <module name="javax.api"/>
     <module name="javax.transaction.api"/>
   </dependencies>
</module>

Adding the postgresql driver in standalone-full.xml file

<subsystem xmlns="urn:jboss:domain:datasources:1.0">
        <datasources>
            .....
            <drivers>
                ...
                <driver name="postgresql" module="org.postgresql">
                    <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
                </driver>
            </drivers>
        </datasources>
    </subsystem>

Creating the gadget server postgresql datasource file, gs-postgresql-ds.xml

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
	<datasource jndi-name="java:jboss/GadgetServer" pool-name="GadgetServer" enabled="true" use-java-context="true">
		<connection-url>jdbc:postgresql://localhost:5432/rtgov</connection-url>
		<driver>postgresql</driver>
		<security>
			<user-name>....</user-name>
			<password>....</password>
		</security>
	</datasource>
</datasources>