Sun GlassFish Web Space Server 10.0 Installation Guide

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.