DbLoader

The reference implementation of uPortal's data storage interfaces requires a relational database. uPortal provides a tool, DbLoader, to load a relational database with the required uPortal tables and sample data.

DbLoader performs the following tasks:

  • Reads in properties/db/tables.xml file to determine the database schema
  • Deletes existing tables specified in tables.xml.
  • Creates the tables specified in tables.xml.
  • Reads in properties/db/data.xml file to determine sample data.
  • Inserts data from data.xml into the newly created tables.
  • Creates a database script containing all the SQL statements previously executed.

DbLoader can be configured by modifying properties/db/dbloader.xml. Because DbLoader relies on database metadata supplied by a JDBC driver, it may be necessary (for some combinations of drivers and databases) to supply a datatype mapping inside dbloader.xml. If this is necessary, DbLoader will print an error message with instructions.

Invoking DbLoader

To run DbLoader, type "ant db" from the uPortal base directory.

The "db" target accepts command line arguments which override values read from the dbloader.xml file.

The "db" target can be invoked thusly:

To use properties/db/mytables.xml instead of the tables file specified in dbloader.xml:
ant db -Dusetable=-t -Dtablefile=/properties/db/mytables.xml

To use /properties/db/mydata.xml instead of the data file specified in dbloader.xml:
ant db -Dusedata=-d -Ddatafile=/properties/db/mydata.xml

Note: the tables and data files can both be overridden by combining the arguments. The usetable and tablefile must be used in tandem and sequentially on the command line. Similarly, usedata and datafile must but used in tandem.

Addtionally, several other boolean flags may be overridden.

To set createScript=true
ant db -Dcreatescript=-c

To set createScript=false
ant db -Dcreatescript=-nc

To set dropTables=true
ant db -Ddroptables=-D

To set dropTables=false
ant db -Ddroptables=-nD

To set createTables=true
ant db -Dcreatetables=-C

To set createTables=false
ant db -Dcreatetables=-nC

To set populateTables=true
ant db -Dpopulatetables=-P

To set populateTables=false
ant db -Dpopulatetables=-nP

The -c, -nc, -D, -nD, -C, -nC, -P, -nP arguements may all be used independantly or in any combination although it would not make sense to, for example, use both -c and -nc.

DbUnload

DbUnload, can read an existing database table and serialize it into an xml file similar to tables.xml. This file can then be used in place of tables.xml to load another database.

To run this target, you must specify the table name and output file parameters
on the command line. For example:
ant dbunload -Dtablename=up_channel -Dxmlfile=mytables.xml