Chapter 11. Creating test databases

11.1. Creating test databases
11.1.1. Get database driver JAR
11.1.2. Set the CLASSPATH
11.1.3. Create a test relational database
11.1.4. Create test XMLDB databases

11.1. Creating test databases

OGSA-DAI contains a set of simple clients to create test datasets. To use these clients you will need to get a driver for the database and then set the CLASSPATH.

11.1.1. Get database driver JAR

Section 3.2, ?Data resource drivers? lists information about data resource products supported by OGSA-DAI and where to get associated database drivers.

You should get the database driver JARs for your data resource and put these in the followig directory in the OGSA-DAI binary distribution:

OGSA-DAI/thirdparty/lib

11.1.2. Set the CLASSPATH

To set the CLASSPATH in an OGSA-DAI binary distribution:

  • If running under Solaris or Linux run:

    $ setenv.sh
    

  • If running under Windows run:

    $ setenv.bat
    

The FAQ "Section C.1.21, ? What do I need in my CLASSPATH to be able to run OGSA-DAI clients or compile OGSA-DAI client examples? ?" describes what is needed in the CLASSPATH to run OGSA-DAI clients if the above are not used.

11.1.3. Create a test relational database

OGSA-DAI provides a set of simple clients to create a test database table called littleblackbook which contains four columns:

  • id - unique ID (key) of type INTEGER.
  • name - first and surname of type VARCHAR(64).
  • address - address of type VARCHAR(128).
  • phone telephone number of type VARCHAR(20).

The number of entries in the table is user-selected. Entries are randomnly created.

11.1.3.1. Create a DB2 test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestDB2DB \
  [-driverclass DRIVER-CLASS] \  Default: com.ibm.db2.jcc.DB2Driver
  [-host HOST-NAME]           \  Default: localhost
  [-port PORT-NUMBER]         \  Default: 50000
  [-database DATABASE-NAME]   \  Default: ogsadai
  [-username USER-NAME]       \  Default: ogsadai
  [-password PASSWORD]        \  Default: ogsadai
  [-tablename TABLE-NAME]     \  Default: littleblackbook
  [-rows NUMBER-OF-ROWS]         Default: 10000

11.1.3.2. Create a MySQL test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestMySQLDB \
  [-driverclass DRIVER-CLASS]    \  Default: org.gjt.mm.mysql.Driver
  [-host HOST-NAME]              \  Default: localhost
  [-port PORT-NUMBER]            \  Default: 3306
  [-database DATABASE-NAME]      \  Default: ogsadai
  [-username USER-NAME]          \  Default: ogsadai
  [-password PASSWORD]           \  Default: ogsadai
  [-tablename TABLE-NAME]        \  Default: littleblackbook
  [-rows NUMBER-OF-ROWS]         \  Default: 10000
  [-rootusername ROOT-USER-NAME] \  Default: root
  [-rootpassword ROOT-PASSWORD]     Default: 

This client also attempts to create the database if one does not exist.

11.1.3.3. Create an Oracle test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestOracleDB \
  [-driverclass DRIVER-CLASS] \  Default: oracle.jdbc.driver.OracleDriver
  [-host HOST-NAME]           \  Default: localhost
  [-port PORT-NUMBER]         \  Default: 1521
  [-database DATABASE-NAME]   \  Default: ogsadai
  [-username USER-NAME]       \  Default: scott
  [-password PASSWORD]        \  Default: tiger
  [-tablename TABLE-NAME]     \  Default: littleblackbook
  [-rows NUMBER-OF-ROWS]         Default: 10000

11.1.3.4. Create a PostgreSQL test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestPostgreSQLDB \
  [-driverclass DRIVER-CLASS] \  Default: org.postgresql.Driver
  [-host HOST-NAME]           \  Default: localhost
  [-port PORT-NUMBER]         \  Default: 5432
  [-database DATABASE-NAME]   \  Default: ogsadai
  [-username USER-NAME]       \  Default: ogsadai
  [-password PASSWORD]        \  Default: ogsadai
  [-tablename TABLE-NAME]     \  Default: littleblackbook
  [-rows NUMBER-OF-ROWS]         Default: 10000

11.1.3.5. Create an SQL Server test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestSQLServerDB \
  [-driverclass DRIVER-CLASS] \  Default: com.microsoft.jdbc.sqlserver.SQLServerDriver
  [-host HOST-NAME]           \  Default: localhost
  [-port PORT-NUMBER]         \  Default: 1433
  [-database DATABASE-NAME]   \  Default: ogsadai
  [-username USER-NAME]       \  Default: ogsadai
  [-password PASSWORD]        \  Default: ogsadai
  [-tablename TABLE-NAME]     \  Default: littleblackbook
  [-rows NUMBER-OF-ROWS]         Default: 10000

11.1.4. Create test XMLDB databases

OGSA-DAI provides a simple client to create a test collection called littleblackbook which contains documents of the following format:


  NAME
  
ADDRESS
PHONE

The number of documents in the collection is user-selected. Entries are randomnly created.

11.1.4.1. Create an eXist test database

Run the following from the command-line:

$ java uk.org.ogsadai.dbcreate.CreateTestExistDB \
  [-driverclass DRIVER-CLASS]       \  Default: org.exist.xmldb.DatabaseImpl
  [-host HOST-NAME]                 \  Default: localhost
  [-port PORT-NUMBER]               \  Default: 8080
  [-database DATABASE-NAME]         \  Default: db
  [-username USER-NAME]             \  Default: ogsadai
  [-password PASSWORD]              \  Default: ogsadai
  [-collectionname COLLECTION-NAME] \  Default: littleblackbook
  [-documents NUMBER-OF-DOCS]          Default: 10000