Sun GlassFish Web Space Server 10.0 Installation Guide

Configuring a Database for Use With Web Space Server

By default, Web Space Server is bundled with an HSQL database that is intended for evaluation purposes only. In most production environments, you will want to use a more robust database, such as MySQL, Oracle, or Microsoft SQL.

The following procedures explain how to configure a database other than HSQL for use with Web Space Server. After performing the instructions for your particular database, be sure to complete the steps in To Connect to a Database Other Than HSQL for final configuration steps common to all databases with Web Space Server.

ProcedureTo Install and Configure MySQL

This procedure describes only the most basic MySQL installation on Solaris with UTF-8 support. The Web Space Server configuration portion of this procedure applies to all platforms. For more detailed MySQL installation instructions, refer to the MySQL installation documentation.

  1. Install MySQL.

    Enter the following commands in a command shell as the root user.


    # groupadd mysql
    # useradd -g mysql mysql
    # cd /usr/local
    # gunzip install-dir/mysql-VERSION-OS.tar.gz | tar xvf -
    # ln -s install-dir/mysql-VERSION-OS mysql
    # cd mysql
    # chown -R mysql .
    # chgrp -R mysql .
    # scripts/mysql_install_db --user=mysql
    # chown -R root .
    # chown -R mysql data
    # bin/mysqld_safe --user=mysql & *
    
  2. Log in to MySQL as the root user.


    bin/mysql -u root
    
  3. Create the Web Space Server database with UTF-8 support.


    create database lportal default character set utf8;
    use lportal;
    grant all privileges on lportal.* to 'lportal'@'localhost' identified by 'lportal';
    

    This example creates a database and a user, both named lportal, but you can use different database and user names, and these names can be whatever you want.

  4. Proceed to To Connect to a Database Other Than HSQL for additional configuration instructions.

ProcedureTo Install and Configure Oracle

This procedure explains how to install configure Web Space Server to work with an Oracle database. Note that this procedure explains on the most basic Oracle installation instructions. For complete Oracle installation instructions, see the Oracle Documentation page.

  1. Download and run the installer for the Oracle package you want to use.

    Refer to the Oracle documentation for complete instructions.

  2. In a command shell, open an Oracle SQL session and create Web Space Server database with UTF-8 support.

    In this example, the new database is named lportal. Use the following commands to create the database:


    CREATE DATABASE lportal
       CHARACTER SET UTF8
       NATIONAL CHARACTER SET AL16UTF16
    
    CHARACTER SET Clause
    

    Note that you cannot specify AL16UTF16 as the CHARACTER SET, although it is acceptable for NATIONAL CHARACTER SET.

    Note also that NATIONAL CHARACTER SET is used for columns specifically defined as NCHAR, NCLOB, or NVARCHAR2. Allowed values are AL16UTF16 (default) and UTF8. See the Oracle Database Globalization Support Guide for information about Unicode data type support.

  3. Create the Web Space Server database user.

    • If using Oracle 10g:

      1. Use a Web browser to connect to the Oracle server, and log in as administrator; for example:


        http://localhost:8080/apex
      2. Click Administration->Database Users->Create Users to create a new user.

        Use the following settings:

        • User name: lportal

        • Password: lportal

        • User privileges: All except for DBA

    • If using Oracle 11g:

      1. Use a Web browser to connect to the Oracle server, and log in as administrator; for example:


        https://localhost:1158/em
      2. Click Servers->Users->Create User to create a new user.

        Use the following settings:

        • User name: lportal

        • Password: lportal

        • User role: DBA

        • Default tablespace: USERS

        • Temporary tablespace: TEMP

  4. Open an Oracle SQL command prompt as administrator, and enter the following commands:


    connect lportal/lportal;
    create schema authorization lportal;
    
  5. Proceed to To Connect to a Database Other Than HSQL for additional configuration instructions.

ProcedureTo Install and Configure Microsoft SQL

This procedure provides basic Microsoft SQL installation instructions, and explains how to configure Microsoft SQL to work with Web Space Server. For complete Microsoft SQL installation instructions see the Microsoft SQL Server page.

Before You Begin

Before proceeding with these instructions, make sure the following are installed on your Web Space Server system:

  1. Install SQL Server Express 2008 with Management Tools.

    Refer to the Microsoft site for complete download and installation instructions.

  2. Navigate to the Microsoft SQL Server Configuration page, and change the following values:

    • Use NT AUTHORITY\SYSTEM as the SQL Server account name.

    • Change the SQL Server browser startup to Automatic.

  3. Navigate to the Microsoft SQL Server Database Engine Configuration page, and change the following values:

    • Select Mixed Node.

    • Specify a password for the sa account.

  4. Start the Microsoft SQL server.

    1. Run the Microsoft SQL Server Configuration Manager.

    2. Navigate to SQL Server Network Configuration->Protocols for SQL SERVER, and enable TCP/IP and Named Pipes (SQL server uses port 1433 by default).

    3. Right click SQL Server Services->SQL Server, and then click Start.

    4. Verify the database is running.

      You can verify this in Solaris by entering netstat -an | grep 1433 at a command prompt:

  5. Connect to the Microsoft SQL server using the Management Studio tool.

    1. Launch the SQL Server Management Studio.

    2. Navigate to File->Connect Object Explorer.

    3. Apply the following settings:

      • Server Type: Database Engine

      • Server Name: host_name

      • Authentication: SQL Server Authentication. Note that to use SQL Server authentication, you need to select the Mixed Mode (Windows authentication + SQL Server authentication) option when installing Microsoft SQL.

      • Login: sa

      • Password: Administrator password defined during Microsoft SQL installation.

    4. Click Connect.

    5. Select New Query in the Management Studio tool.

    6. Enter create database lportal, and then click Execute.

      The message “Query executed successfully” is displayed on successful creation of the database named lportal.

  6. Download the jtds JDBC driver from http://jtds.sourceforge.net/.

  7. Copy the jtds.jar file to the gf-install-dir/domains/domain1/lib directory.

  8. Proceed to To Connect to a Database Other Than HSQL for additional configuration instructions.

ProcedureTo Connect to a Database Other Than HSQL

This procedure describes how to connect Web Space Server to a database other than HSQL. The instructions are basically the same for connecting to MySQL, Oracle, or Microsoft SQL.

Before You Begin

Make sure you have followed the initial configuration instructions for your particular database.

  1. Create a directory structure, if it does not already exist, named webspace/WEB-INF/classes/ under ws-install-dir/var/webspace/war-workspace/customs.

    Note that if you have started the Web Space Server domain at least once after the initial Web Space Server installation, this directory will already exist. If you have not yet started Web Space Server for the first time, you will need to create this directory structure yourself.

  2. Change to the webspace/WEB-INF/classes/ directory mentioned above.

  3. Create a text file (using any text editor) named portal-ext.properties, if this file does not already exist.

    As with Step 1 of this procedure, this file will already exist if you have started Web Space Server at least once after initial installation, otherwise you will need to create the portal-ext.properties file yourself.

  4. Enable the database you want to use by entering the following uncommented properties in the portal-ext.properties file.

    Be sure that hash marks do not proceed any of the jdbc.* properties. Also make sure to use the correct user_name and password for your database.

    • For MySQL:


      # MySQL
          #
          jdbc.default.driverClassName=com.mysql.jdbc.Driver
          jdbc.default.url=jdbc:mysql://localhost/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
          jdbc.default.username=user_name
          jdbc.default.password=password
      

      Note –

      To use a database name other than lportal, specify the name in the jdbc.default.url property, above, just after the mysql://localhost portion of the URL.


    • For Oracle:


      # Oracle
          #
          jdbc.default.driverClassName=oracle.jdbc.driver.OracleDriver
          jdbc.default.url=jdbc:oracle:thin:@localhost:1521:xe
          jdbc.default.username=lportal
          jdbc.default.password=lportal

      Note –

      If running Oracle 11g, also add the following property:


      hibernate.dialect=org.hibernate.Oracle10gDialect

    • For Microsoft SQL:


      # SQL Server
          #
          jdbc.default.driverClassName=net.sourceforge.jtds.jdbc.Driver
          jdbc.default.url=jdbc:jtds:sqlserver://localhost:1433/lportal
          jdbc.default.username=sa
          jdbc.default.password=admin_password
      
  5. Change to the ws-install-dir/var/webspace/war-workspace directory.


    Note –

    If you are performing a new Web Space Server installation rather than updating the database configuration for an existing Web Space Server installation, skip this step and the remainder of this procedure.


  6. Run the Ant synchronize.xml script.


    ant -f synchronize.xml
    
  7. Restart the GlassFish server.