Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Warning

This page has not been updated for uPortal 3.0 and the information contained may not be correct.

Overview

DB2 is a commercial database from IBM. The DB2 database software is availble from IBM at:
http://www.ibm.com/software/data/db2/

Obtaining the Driver

Since the DB2 JDBC driver is not available in the central Maven repository, it must be placed into the local repository of each machine on which you wish to build uPortal.

As an alternative to this, you could set up a maven repository for use by multiple machines.

A JDBC DB2 driver is included in the DB2 software in the java subdirectory after DB2 installation has been performed. The file db2java.zip should be copied to a location that is accessible from the uPortal build environment (for example, /usr/local/java/db2/lib/db2jdbc.zip).

See Issues section about possible issues using this driver.

Properties Configuration

The uPortal build.properties may need to be modifed. Find the property called jdbcDriver and change it to point to the DB2 jar file, for example:

Code Block
jdbcDriver.jar=./lib/db2java.zip

The uPortal rdbm.properties file (in the properties directory) may need to modified to specify the driver properties. The rdbm.properties file contains several sample entries. Uncomment (or add) the lines for the DB2 database and make whatever changes necessary to match your local database installation, For example:

Code Block

    #### DB2
    jdbcDriver=COM.ibm.db2.jdbc.net.DB2Driver
    jdbcUrl=jdbc:db2://localhost/uportal
    jdbcPassword=sa
    jdbcPassword= 

The dbloader.xml properties file (also in the properties directory) may also need to be modified. This file is used by the DbLoader tool to create the uPortal database tables and populate the database. It contains several sample entries which create db-type-mappings for different databases. Find the tags for an DB2 database and modify the db-version, driver-name, and driver-version as necessary. For example:

Code Block

    <db-type-mapping>
      <db-name>DB2</db-name>
      <db-version>7.2</db-version>
      <driver-name>DB2 Driver</driver-name>
      <driver-version>7.2</driver-version>
      <type><generic>INTEGER</generic><local>INTEGER</local></type>
      <type><generic>VARCHAR</generic><local>VARCHAR</local></type>
      <type><generic>LONGVARCHAR</generic><local>LONGVARCHAR</local></type>
      <!-- map more types here -->
    </db-type-mapping>

The PersonDirs.xml file (also in the properties directory) may need to be modified; This file is used if the database is to be used to provide user directory information

...

To install the JAR into your local maven repository, use the following command:

No Format

mvn install:install-file -DgroupId=com.ibm.db2 -DartifactId=db2-jdbc -Dversion=<version> -Dpackaging=jar -DgeneratePom=true -Dfile=db2java.zip.jar

The groupId, artifactId and version specified in this command are up to you, but they should match the JAR vendor, name and version to avoid confusion down the road.

JAR Configuration

Opening /uPortal/pom.xml, there is a section about 92 lines down that reads:

Code Block
xml
xml

    <!-- The JDBC Driver used by uPortal -->
    <jdbc.groupId>hsqldb</jdbc.groupId>
    <jdbc.artifactId>hsqldb</jdbc.artifactId>
    <jdbc.version>${hsqldb.version}</jdbc.version>

Modify this to use the DB2 driver, using the group, artifact and version information from the mvn install:install-file command above.

Code Block
xml
xml
    <!-- The JDBC Properties Driver used by uPortal -->
    <driver>org<jdbc.groupId>com.hsqldbibm.jdbcDriver<db2</driver>jdbc.groupId>
    <url>jdbc:db2://localhost/uportal</url><jdbc.artifactId>db2-jdbc</jdbc.artifactId>
    <logonid>sa</logonid>
    <logonpassword></logonpassword>,
    <uidquery>SELECT FIRST_NAME||' '||LAST_NAME AS FIRST_LAST,
    FIRST_NAME, LAST_NAME, EMAIL FROM UP_PERSON_DIR WHERE USER_NAME=?></uidquery> 

Loading the Database

Loading the database requires a couple of steps

  • Create the database: Refer to the DB2 database documentation for instructions regarding how to create an DB2 database instance. DB2 uses a properties file for describing and tuning the database. The properties in that file will need to match definitions in the rdbm.properties file.
  • Create the tables and populate the database: From the uPortal build directory, run "ant db" to execute the ant target which loads the database. The ant target uses the Dbloader tool.

Additional Notes

<jdbc.version>version</jdbc.version>

JDBC Configuration

Edit /uPortal/uportal-impl/src/main/resources/properties/rdbm.properties by adding the following information for MSSQL, modifying the url, username and password as appropriate:

Code Block

##### DB2 Server
hibernate.connection.driver_class=COM.ibm.db2.jdbc.app.DB2Driver
hibernate.connection.url=jdbc:db2:uPortal3Db
hibernate.connection.username=test
hibernate.connection.password=mypass
hibernate.dialect=cirrus.hibernate.sql.DB2Dialect

Testing the Configuration

Running the dbtest ant target will tell you if you have configured the database connection properly.

Code Block

ant dbtest

Then, following a successful test, you can execute

Code Block

ant initportal

to build the database tables and copy files to your servlet container.

Issues and Known Bugs

Some people have encountered problems with database drivers with certain web application environments if the classes zip file is used as-is with the .zip file extension. Simply renaming the file to a .jar file seems to fix the problem. Alternatively, unzipping the classes file into a directory structure, then using the jar command to repackage the classes into a jar file works as well.

Warning
iconfalse
titleHaving problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org