Configuring a database environment

This chapter outlines how to create a clean database that will contain metadata for NexJ CRM. Use NexJ Studio to configure connections to the database, as well as to create and populate the database.

To create tables, drop tables, and insert data into tables, you need the appropriate database role. In order to use NexJ Studio Data Load Tool commands recreate, recreateschema, and insert, you need create and drop permissions for database objects; security granting permissions to update the permissions on those newly created objects; and read/write access to the newly created objects.

If you cannot perform these tasks against the database, you must generate SQL scripts using the Database Schema Tool and have a user with the appropriate permissions execute the scripts.

If the initial database creation SQL scripts are provided to you by NexJ, they can be customized to meet naming conventions and standards. Work with your NexJ representative to ensure you are modifying the scripts correctly. Otherwise, you can generate these scripts in NexJ Studio by using the setup command in the Database Schema Tool.

To configure a database environment for your NexJ application, you need to create the default relational database and create data source connections. After configuring the default relational database, you create the database schema for the data sources and insert data into them.

The general steps to configuring a database environment are as follows:
  1. Prepare a script for which will create the required database on the database server.
    • If the dbtype_create_database.sql file (where dbtype is the type of the database server) was provided to you by NexJ, edit this file to make it applicable to your specific deployment. Configure the database name, user name, file location, database names, tables, and file names.
    • In NexJ Studio, use the setup command in the Database Schema Tool to generate a dataSourceConnection_setup.sql setup script, where dataSourceConnection is the data source listed in the connections file for the model. You can generate a script for each required data source. See Generating database schema SQL.
      Note: When generating the script using the setup command, ensure that the Test option in the Server and Connections section of the Database Schema Tool dialog is not enabled. Otherwise, the script will additionally configure the user generating the script as the db_owner role and give this user too many privileges for a production environment.
      Note: When generating the script using the setup command, in the VM Arguments section of the Database Schema Tool dialog, ensure that the directories specified for the following parameters exist on the machine where the script will be run:
      • datapath
      • indexpath
      • longpath
      • undopath
  2. Run the script against the database. This script creates the new default relational database that stores the NexJ metadata information. The setup script also generates a database role or group of njdbuser. If you wish to alter this name, work with your NexJ representative to have it changed.
    Note: Any defined file name paths must exist prior to executing the script. If any paths do not exist, create them. Otherwise, the script will fail.
  3. If you are deploying to JBoss AS, generate the script for creating JMS tables and run it against the database. See Configuring a different database for JMS tables and generating a script to create JMS tables for more information.
  4. Add the required data sources to your connections or environment file and configure each data source as required. A list of required data sources with sample connections can be found here: Example XML environment file for NexJ CRM deployment on NexJ Server.
  5. Add the required channel connections and configure each channel as required. A list of required channels with sample configurations can be found here: Channel connection settings.
  6. Add the required SOA connections and configure each channel as required. A list of required SOA connections with sample configurations can be found here: SOA connection settings.
  7. Create the schema and data in the database for the added data sources.
    • Use the Data Load Tool recreate command to both recreate the database schema and populate the tables, optionally from a dump file. You must have the appropriate permission to drop and create tables in the database. See Recreating databases for information on using the Data Load Tool.
    • Use the Database Schema Tool create command to generate scripts for creating the database schema and the insert command to generate scripts to populate the tables using system default data or data from a dump file. Separate scripts must be created for each data source. See Creating database tables and Generating the initial database data for deployment for information on generating the appropriate scripts.
The database environment has now been configured.
Each database server also has additional settings and best practices that can be configured. See the corresponding list for your database server.