MS SQL Server and MS JDBC Driver
Step 1: Obtain the MS JDBC driver
Microsoft has now open sourced their MS SQL Server JDBC driver and added it to the central Maven repository. This step is now part of the build process.
Step 2: Configure the Database Filter
From the uPortal source directory, open the filters/ properties file you wish to use with MS SQL Server and add your database information
## HSQL Configuration
environment.build.hsql.port=8887
## Database Connection Settings (Uncomment the Maven Filters section in rdbm.properties)
environment.build.hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver
environment.build.hibernate.connection.url=jdbc:sqlserver://<servername>:<port>;databaseName=<databasename>
environment.build.hibernate.connection.username=<username>
environment.build.hibernate.connection.password=<password>
environment.build.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
environment.build.hibernate.connection.validationQuery=select 1
Step 3: Add the database driver
NEW: Open uportal-db/pom.xml file, uncomment the MSSQL sqljdbc driver below and modify as needed
Add the appropriate version properties to the root pom.xml file or enter the appropriate version below. Valid options are "6.1.0.jre7" and "6.1.0.jre8" as of this edit.
uportal-db/pom.xml
...
<dependencies>
<!-- Add any db drivers that are applicable to *any* of your environments -->
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
<scope>compile</scope>
</dependency>
<!--
| The following db drivers should be uncommented and/or modified as needed for server
| deployments. (Add all thaat are needed.) Don't forget to add appropriate .version
| properties to the root pom.xml, or simply enter the appropriate version below.
+-->
<!--
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>db2-jdbc</artifactId>
<version>${db2.version}</version>
<scope>compile</scope>
</dependency>
-->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql.version}</version>
</dependency>
<!--
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6_g</artifactId>
<version>${oracle.version}</version>
</dependency>
<dependency>
<groupId>org.sybase</groupId>
<artifactId>sybase-jconnect</artifactId>
<version>${sybase.version}</version>
</dependency>
-->
</dependencies>
Step 4: Test the Configuration
Running the dbtest ant target will tell you if you have configured the database connection properly.
ant dbtest
Step 5: Build and Deploy
Following a successful test, you can execute the command below to build the database tables and copy files to your servlet container.
Note: Executing the command "ant clean initportal" will drop and recreate the database tables and all existing data will be lost. This will result in a clean uPortal database structure. If you want to keep the contents of your existing database, use "ant clean deploy-war"
ant clean initportalStep 6: Restart Tomcat
Additional References
Having problems with these instructions?
Please send us feedback at uportal-user@lists.ja-sig.org
We have been testing uPortal 4.0.x with SQL Server 2008 R2 and SQLJDBC4 driver and can add a few points to the instructions:
1)
environment.build.hibernate.dialectorg.jasig.portal.utils.PortalDialectResolver is programmed to return an instance of
org.hibernate.dialect.SQLServer2005Dialectfor SQL Server v. 2008 and above. This was done when jTDS drivers (1..2.x) did not support SQL Server 2008+ - see https://apereo.atlassian.net/browse/UP-3358.With jTDS 1.3.x - and definitely with sqljdbc4.jar,
org.hibernate.dialect.SQLServer2008Dialectcan be used. We had to update the above class in our deployment as well - and not just set the dialect in the properties file.2)
environment.build.hibernate.connection.urlWe were getting "aggregateRawEvents failed" errors due to the following "The data types time and datetime are incompatible in the greater than or equal to operator." As described in this blog - http://blogs.msdn.com/b/jdbcteam/archive/2010/04/08/using-time-and-date-data-types-part-1-what-time-is-it.aspx - JDBC driver needs to be told explicitly to use the time data type rather than the datetime data type with setTime/updateTime by setting the connection property "sendTimeAsDateTime=false":
environment.build.hibernate.connection.url=jdbc:sqlserver://<servername>:<port>;databaseName=<databasename>;sendTimeAsDateTime=false