Chapter 35. Create test data

35.1. Get database driver JARs
35.2. Create relational test data
35.2.1. Create DB2 test data
35.2.2. Create MySQL test data
35.2.3. Create Oracle test data
35.2.4. Create PostgreSQL test data
35.2.5. Create SQL Server test data
35.3. Create XMLDB test data
35.3.1. Create eXist test data

OGSA-DAI contains a set of simple clients to create test data. These do not use OGSA-DAI - they talk directly to the database. These clients are for users who do not have their own data but want to explore OGSA-DAI.

If you already have data then please skip on to Chapter 36, Deploy Globus Toolkit.

You should already have the database driver JARs for your database. If not then we listed suitable drivers earlier in Chapter 27, Data resource products and you should get them now.

35.1. Get database driver JARs

You should put the database driver JARs into the following directory:

$OGSADAI_HOME/thirdparty/lib

You'll now need to add the JARs to your CLASSPATH.

  • If running under Solaris or Linux run the following command for each driver JAR you have, remembering to replacedatabase.jar with the name of your database JAR each time.

    $ export CLASSPATH=$OGSADAI_HOME/thirdparty/lib/database.jar:$CLASSPATH
    

  • If running under Windows run the following command for each driver JAR you have, remembering to replacedatabase.jar with the name of your database JAR each time.

    $ set CLASSPATH=%OGSADAI_HOME%\thirdparty\lib\database.jar;$CLASSPATH
    

35.2. Create relational test data

OGSA-DAI provides 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 can be chosen by you - the default is 10000 - as can the table name - the default is littleblackbook and driver class name.

  • A different table name can be chosen by adding a -tablename option e.g. adding the argument -tablename myTable would ensure the new table is called myTable
  • A different number of rows be chosen by adding a -rows option e.g. adding the argument -rows 100 would ensure the new table has 100 rows.
  • A different driver class can be chosen by adding a -driverclass option e.g. adding the argument -driverclass my.own.Driver would ensure the client uses the driver my.own.Driver

35.2.1. Create DB2 test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, USER and PASSWORD with the host, port, login name and password of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestDB2DB -host HOST -port PORT -database DATABASE -username USER -password PASSWORD

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestDB2DB -host coal.epcc.ed.ac.uk -port 5000 -database ogsadai -username db2user -password 123456

35.2.2. Create MySQL test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, USER and PASSWORD with the host, port, login name and password of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestMySQLDB -host HOST -port PORT -database DATABASE -username USER -password PASSWORD

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestMySQLDB -host coal.epcc.ed.ac.uk -port 3306 -database ogsadai -username mysqlUser -password 123456

35.2.2.1. Create MySQL test database

If you don't have a test database then this client will create one if you give it two more arguments - rootusername and rootuserpassword. For example:

$ java uk.org.ogsadai.dbcreate.CreateTestMySQLDB -host coal.epcc.ed.ac.uk -port 3306 -database ogsadai -username mysqlUser -password 123456 -rootusername ogsadairootuser -rootpassword ogsadairootpassword

will connect to MySQL using rootusername, create a database called ogsadai, create a user mysqlUser with password 123456 and then create the littleblackbook table.

35.2.3. Create Oracle test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, USER and PASSWORD with the host, port, login name and password of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestOracleDB -host HOST -port PORT -database DATABASE -username USER -password PASSWORD

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestOracleDB -host coal.epcc.ed.ac.uk -port 1521 -database ogsadai -username oracleUser -password 123456

35.2.4. Create PostgreSQL test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, USER and PASSWORD with the host, port, login name and password of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestPostgreSQLDB -host HOST -port PORT -database DATABASE -username USER -password PASSWORD

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestPostgreSQLDB -host coal.epcc.ed.ac.uk -port 1521 -database ogsadai -username postgresUser -password 123456

35.2.5. Create SQL Server test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, USER and PASSWORD with the host, port, login name and password of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestSQLServerDB -host HOST -port PORT -database DATABASE -username USER -password PASSWORD

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestSQLServerDB -host coal.epcc.ed.ac.uk -port 1433 -database ogsadai -username sqlServerUser -password 123456

35.3. Create XMLDB test data

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

<entry id="ID">
  <name>NAME</name>
  <address>ADDRESS</address>
  <phone>PHONE</phone>
</entry>

The number of documents in the collection can be chosen by you. The default is 10000. Entries are randomly created.

The number of documents in the collection can be chosen by you - the default is 10000 - as can the collection name - the default is littleblackbook and driver class name.

  • A different collection name can be chosen by adding a -collectionname option e.g. adding the argument -collectionname myCollection would ensure the new table is called myCollection
  • A different number of documents be chosen by adding a -documents option e.g. adding the argument -documents 100 would ensure the new collection has 100 documents.
  • A different driver class can be chosen by adding a -driverclass option e.g. adding the argument -driverclass my.own.Driver would ensure the client uses the driver my.own.Driver

35.3.1. Create eXist test data

Run the following from the command-line, remembering to replace HOST, PORT, DATABASE, with the host, port and database name of your database:

$ java uk.org.ogsadai.dbcreate.CreateTestExistDB -host HOST -port PORT -database DATABASE

e.g.

$ java uk.org.ogsadai.dbcreate.CreateTestExistDB -host coal.epcc.ed.ac.uk -port 8080 -database db

35.3.1.1. Create eXist users

The default eXist username is admin with an empty password. You can create a username and password for as follows:

  1. Start up eXist.
  2. In a browser visit the eXist URL e.g. for the example above this would be:
    http://coal.epcc.ed.ac.uk:8080/exist
    
  3. Click the Admin link on lower-left side of the eXist page.
  4. Log in using the admin user name and no password.
  5. Click the Manage Users link.
  6. Click the New User link.
  7. Enter a new username and password, group and default collection e.g.
    • User name : ogsadai
    • Password: ogsadai
    • Group: guest
    • Collection: /db/littleblackbook

For more information on configuring eXist logins see: http://exist.sourceforge.net/security.html

If you have a full eXist download you could use their Java client. This is in the eXist installation directory and can be run using

$ ./bin/client.sh

You should update the connection URL with your host and port number then you can use the Tools=>Edit Users menu option to add more users.

For more information using the eXist client see: http://exist.sourceforge.net/client.html