Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

MySQL is a free, open source database, available for download at http://dev.mysql.com/ (more information can also be found at http://www.mysql.com) - also at this address, the JDBC driver for MySQL, Connector/J, can be downloaded. The Generally Available (GA) release is usually what is desired - it is best to use this instead of the Beta versions. For information on how to create a database in MySQL or create the tables, you will need to refer to the documentation that came with the version of MySQL you have decided to use. There are links to MySQL documentation as well on the above site.

Below are the steps required to integrate MySQL with uPortal

MySQL Configuration

Table Type

uPortal relies on database transactional support, which in MySQL is dependent upon the underlying storage engine (per-table). The default (MyISAM) is not transaction safe. The most common transactional table type on MySQL is InnoDB. You configure InnoDB as the default:

...

Before using MySQL with uPortal, several uPortal properties files need to be altered for MySQL. These include:

pom.xml

In the top level pom.xml file, you should replace 

Code Block

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

with 

...

JAR Configuration

The first step is to determine the correct information to use in the pom. Using a Maven Artifact Search Site and searching for "mysql" we find the following Maven dependency declaration here.

Code Block
xml
xml

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
</dependency>

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

Code Block
xml
xml
<!-- The JDBC Driver used by uPortal -->
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.1.6</jdbc.version>

rdbm.properties

...

JDBC Configuration

Edit /uPortal/uportal-impl/src/main/resources/properties/rdbm.properties and add the lines for MySQL. Modify the URL, username and password as appropriate:

Code Block
##### MySQL - example
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.connection.url=jdbc:mysql://my.school.edu:3306/portal
hibernate.connection.username=test
hibernate.connection.password=mypass
hibernate.dialect=org.hibernate.dialect.MySQLDialect

dbloader.xml

...


The /uPortal/uportal-impl/src/main/resources/dbproperties/dbloader.xml 
You need to add a mapping specific to you setup, for xml properties file 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 MySQL database and modify the db-version, driver-name, and driver-version as necessary. For example:

Code Block
<db-type-mapping>
       <db-name>MySQL</db-name>
       <db-version>5.0.32-Debian_7etch5-log</db-version>
       <driver-name>MySQL-AB JDBC Driver</driver-name>
       <driver-version>mysql-connector-java-5.0.8 ( Revision: ${svn.Revision} )</driver-version>
       <type><generic>LONGVARCHAR</generic><local>TEXT</local></type>
</db-type-mapping> mapping>

personDirectoryContext.xml 

...

The /uPortal/uportal-impl/src/main/resources/contexts/personDirectoryContext.xml properties file will also need to be modified.

Replace

Code Block
<value>   <value>
SELECT FIRST_NAME||' '||LAST_NAME AS FIRST_LAST, FIRST_NAME, LAST_NAME, EMAIL, USER_NAME
FROM UP_PERSON_DIR
WHERE USER_NAME=?
</value>

 with

Code Block
<value>   <value>
SELECT CONCAT(FIRST_NAME,' ',LAST_NAME) AS FIRST_LAST, FIRST_NAME, LAST_NAME, EMAIL, USER_NAME
FROM UP_PERSON_DIR
WHERE USER_NAME=?
</value>

...

One thing that will most likely come up in working with uPortal and MySQL (or any database for that matter) is the issue of deadlocks - when a record is needed to be accessed by two different queries at the same time. The MySQL site has an EXCELLENT chapter on dealing with these. Overall, the on-line reference guide for MySQL is an EXCELLENT resource.

Resources

...

Download driver / connector; http://dev.mysql.com/downloads/connector/j/5.0.html

Testing The Configuration

Start MySQL and then in your portal development directory, issue the command:

No Format

ant dbtest

If it works correctly you should see something like

No Format

Buildfile: build.xml



Verify the values on the Database name, Database version, Driver name, Driver version match those entered in dbloader.xml exactly.