Versions Compared

Key

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

...

This was written for version 2.4.2 but should work on 2.5.* and earlier version of uPortal as well.

...

Code Block

jdbcDriver=org.postgresql.Driver
jdbcUrl=jdbc:postgresql://localhost:5432/portal
jdbcUser=postgres
jdbcPassword=

...

Code Block

<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/portal</url>
<logonid>postgres</logonid>
<logonpassword></logonpassword>

...

Code Block

ant dbtest

...

Code Block


% ant dbtest
Buildfile: build.xml

prepare:

compile:
     [UPC:copy] Copying 2 files to C:\portal\build\WEB-INF\classes\properties

dbtest:
     [UPC:echo] Invoking DbTest
     [UPC:java] Database name: 'PostgreSQL'
     [UPC:java] Database version: '7.4.5'
     [UPC:java] Driver name: 'PostgreSQL Native Driver'
     [UPC:java] Driver version: 'PostgreSQL 7.4.5 JDBC3 with SSL (build 215)'
     [UPC:java] Driver class: 'org.postgresql.Driver'
     [UPC:java] Connection URL: 'jdbc:postgresql://localhost:5432/test'
     [UPC:java] User: 'postgres'
     [UPC:java] supportsANSI92EntryLevelSQL: true
     [UPC:java] supportsANSI92FullSQL: false
     [UPC:java] supportsCoreSQLGrammar: false
     [UPC:java] supportsExtendedSQLGrammar: false
     [UPC:java] supportsTransactions: true
     [UPC:java] supportsMultipleTransactions: true
     [UPC:java] supportsOpenCursorsAcrossCommit: false
     [UPC:java] supportsOpenCursorsAcrossRollback: false
     [UPC:java] supportsOpenStatementsAcrossCommit: true
     [UPC:java] supportsOpenStatementsAcrossRollback: true
     [UPC:java] supportsStoredProcedures: false
     [UPC:java] supportsOuterJoins: true
     [UPC:java] supportsFullOuterJoins: true
     [UPC:java] supportsLimitedOuterJoins: true
     [UPC:java] supportsBatchUpdates: true
     [UPC:java] supportsColumnAliasing: true
     [UPC:java] supportsExpressionsInOrderBy: true
     [UPC:java] supportsOrderByUnrelated: true
     [UPC:java] supportsPositionedDelete: false
     [UPC:java] supportsSelectForUpdate: true
     [UPC:java] supportsUnion: true
     [UPC:java] supportsUnionAll: true

     [UPC:java] getMaxColumnNameLength: 63
     [UPC:java] getMaxColumnsInIndex: 32
     [UPC:java] getMaxColumnsInOrderBy: 0
     [UPC:java] getMaxColumnsInSelect: 0
     [UPC:java] getMaxColumnsInTable: 1600
     [UPC:java] getMaxConnections: 8192
     [UPC:java] getMaxCursorNameLength: 63
     [UPC:java] getMaxIndexLength: 0
     [UPC:java] getMaxRowSize: 1073741824
     [UPC:java] getMaxStatements: 1
     [UPC:java] getMaxTableNameLength: 63
     [UPC:java] getMaxTablesInSelect: 0
     [UPC:java] getMaxUserNameLength: 63
     [UPC:java] getSearchStringEscape: \\

     [UPC:java] Table Types: INDEX,SEQUENCE,SYSTEM INDEX,SYSTEM TABLE,SYSTEM TOAST I
NDEX,SYSTEM TOAST TABLE,SYSTEM VIEW,TABLE,TEMPORARY INDEX,TEMPORARY TABLE,VIEW
     [UPC:java] SQL Types: bool,bytea,char,name,int8,int2,int2vector,int4,regproc,te
xt,oid,tid,xid,cid,oidvector,SET,pg_type,pg_attribute,pg_proc,pg_class,pg_shadow
,pg_group,pg_database,smgr,point,lseg,path,box,polygon,line,_line,float4,float8,
abstime,reltime,tinterval,unknown,circle,_circle,money,_money,macaddr,inet,cidr,
_bool,_bytea,_char,_name,_int2,_int2vector,_int4,_regproc,_text,_oid,_tid,_xid,_
...............

...

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 "postgres" we find the following Maven dependency declaration here.

Code Block
xml
xml

<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>8.2-507.jdbc4</version>
</dependency>

Opening /uPortal/uportal-impl/pom.xml there is a section about 20 lines down that reads:

Code Block
xml
xml

<!-- ***** Portal JDBC Driver *****
 | Add your JDBC Driver dependency here. If you are not using hsqldb you must change the scope
 | to test instead of just removing it as the driver is required for unit tests. 
 +-->
<dependency>
    <groupId>hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>${hsqldb.version}</version>
    <scope>compile</scope>
</dependency>

We will add the PostgreSQL driver here and do as the comment says and change the <scope> tag of the hsqldb driver to test.

Code Block
xml
xml

<!-- ***** Portal JDBC Driver *****
 | Add your JDBC Driver dependency here. If you are not using hsqldb you must change the scope
 | to test instead of just removing it as the driver is required for unit tests. 
 +-->
<dependency>
    <groupId>postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>8.2-507.jdbc4</version>
</dependency>

<dependency>
    <groupId>hsqldb</groupId>
    <artifactId>hsqldb</artifactId>
    <version>${hsqldb.version}</version>
    <scope>test</scope>
</dependency>

JDBC Configuration

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

Code Block

##### PostgreSQL - example
hibernate.connection.driver_class=org.postgresql.Driver
hibernate.connection.url=jdbc:postgresql://my.school.edu/portal
hibernate.connection.username=test
hibernate.connection.password=mypass
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

Testing The Configuration

Start Postgres.
In your portal development directory, issue the command

Code Block

ant dbtest

If it works correct you should see something like

Code Block

TODO
  1. Edit /uPortal/uportal-impl/src/main/resources/properties/db/dbloader.xml and verify that there is an entry just like the database version you displayed in the last step:
    Code Block
      <db-type-mapping>
        <db-name>PostgreSQL</db-name>
        <db-version>7.4.5</db-version>
        <driver-name>PostgreSQL Native Driver</driver-name>
        <driver-version>PostgreSQL 7.4.5 JDBC3 with SSL (build 215)</driver-version>
        <type><generic>LONGVARCHAR</generic><local>TEXT</local></type>
        <type><generic>VARCHAR</generic><local>VARCHAR</local></type>
        <type><generic>LONGVARBINARY</generic><local>BYTEA</local></type>
        <type><generic>VARBINARY</generic><local>BYTEA</local></type>
        <type><generic>BLOB</generic><local>OID</local></type>
      </db-type-mapping>
    
    If there is not an exact match, then add it.
  2. Execute
    Code Block
    ant db
    to build the database tables
  3. Execute
    Code Block
    ant deploy
    to copy files to your servlet container
  4. Start your servlet container.

...