Wednesday, September 8, 2010

JBoss postgresql datasource

Add the following application-policy to server/default/conf/login-config.xml :

    <application-policy name="EncryptSvomPostgresDBPassword">
        <authentication>
            <login-module code="org.jboss.resource.security.SecureIdentityLoginModule" flag="required">
                <module-option name="username">svom</module-option>
                <module-option name="password">-6ea6dc30b0f7071b9bdb31f2b24f1817</module-option>
                <module-option name="managedConnectionFactoryName">jboss.jca:name=SvomPostgresDS,service=LocalTxCM</module-option>
            </login-module>
        </authentication>
    </application-policy>

Define the datasource in the deploy directory as :

  <local-tx-datasource>
    <jndi-name>SvomPostgresDS</jndi-name>
    <connection-url>jdbc:postgresql://dappce159.extra.cea.fr:5432/svom_db</connection-url>
    <driver-class>org.postgresql.Driver</driver-class>
    <security-domain>EncryptSvomPostgresDBPassword</security-domain>
                <min-pool-size>1</min-pool-size>
                <max-pool-size>20</max-pool-size>
        <!-- sql to call when connection is created.  Can be anything, select 1 is valid for PostgreSQL
        <new-connection-sql>select 1</new-connection-sql>
        -->

        <!-- sql to call on an existing pooled connection when it is obtained from pool.  Can be anything, select 1 is valid for PostgreSQL
        <check-valid-connection-sql>select 1</check-valid-connection-sql>
        -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) 
      <metadata>
         <type-mapping>PostgreSQL 8.0</type-mapping>
      </metadata> -->
  </local-tx-datasource>