GenericDBProxy - Configuration

From Wesip

From Wesip

As explained in the code section the application uses JNDI datasources to acess to the databases. To publish database pools like JNDI datasources some configuration tasks have to be accomplished in both the application server and in the application itself.

The first we have to do is declare the JNDI databases in the configuration file of the application server. The name of the file is server.xml and is located in the conf directory in the root of the installation. Edit the file, look for the DefaultContext section and add as many resources as databases.

 <DefaultContext useNaming="true" reloadable="true">
     <Resource name="databaseBAR" auth="WeSIP"  type="javax.sql.DataSource"/>
     <Resource name="databaseFOO" auth="WeSIP"  type="javax.sql.DataSource"/>
       <ResourceParams name="databaseBAR">
           <parameter>
                   <name>username</name>
                   <value>SCOTT</value>
           </parameter>
           <parameter>
                   <name>password</name>
                   <value>TIGER</value>
           </parameter>
           <parameter>
                   <name>driverClassName</name>
                   <value>oracle.jdbc.driver.OracleDriver</value>
           </parameter>
           <parameter>
                   <name>url</name>
                   <value>jdbc:oracle:thin:@10.0.0.100:1521:ORCL</value>
           </parameter>
           <parameter>
                   <name>maxActive</name>
                   <value>2</value>
           </parameter>
           <parameter>
                   <name>maxIdle</name>
                   <value>4</value>
           </parameter>
   </ResourceParams>
   <ResourceParams name="databaseFOO">
           <parameter>
                   <name>username</name>
                   <value>jessy</value>
           </parameter>
           <parameter>
                   <name>password</name>
                   <value>james</value>
           </parameter>
           <parameter>
                   <name>driverClassName</name>
                   <value>org.postgresql.Driver</value>
           </parameter>
           <parameter>
                   <name>url</name>
                   <value>jdbc:postgresql://10.0.0.102:5432/provision</value>
           </parameter>
           <parameter>
                   <name>maxActive</name>
                   <value>2</value>
           </parameter>
           <parameter>
                   <name>maxIdle</name>
                   <value>4</value>
           </parameter>
   </ResourceParams>
 </DefaultContext>

You can add as many as you want. The procedure is always the same. First you declare the resource itselft

<Resource name="databaseBAR" auth="WeSIP" type="javax.sql.DataSource"/>

then configure the driver, username, password, URL and max/min users with the ResourceParams section.

<ResourceParams name="databaseBAR">
  ....  

With the application server configured now you have to configure the application. Edit the deployment descriptor sip.xml, web.xml or both and add the following section

 <resource-ref>
   <description>
      Database Access to databaseBAR
   </description>
   <res-ref-name>databaseBAR</res-ref-name>
   <res-type>javax.sql.DataSource</res-type>
   <res-auth>WeSIP</res-auth>
 </resource-ref>

One resource-ref per database is required. Note that res-ref-name must exactly match the resource name attribute just like 'res-auth' must match 'auth'.

Master Database Configuration

The master database maps application prefixes to statement data through the GENERIC_DB_PROXY_CONF table. The table must have two varchar columns named APP_PREFIX and CONF_STRING.

<< Code