5.9.1 Configuring Database Parameters

Overview

 

On selecting the database of your choice, there are certain configurations that you must effect for proper functioning. You can configure the database parameters like database location, driver name etc., by simply editing a configuration file.

This document explains such configurations possible and answers the following questions:

 



 

All of the above parameters can be configured in the hibernate.cfg.xml file.

 

Location of the Configuration file

 

The hibernate.cfg.xml file is present under <Web NMS Home>/classes/hbnlib/ directory.

 

How to use the configuration file?

 

There are 5 set of entries in the file one each for MySQL, Oracle, Sybase, PostgreSQL, and MSSQL database applications. Un-comment only one set of entries based on the databases to be used and let the other set of entries remain commented. By default, MySQL database entries remain un-commented and the other set of entries remain commented.

The parameters in this file have to be altered before starting the Web NMS Server. Any changes in this file, during Server run-time, requires a cold start of the Server for the changes to take effect.

 

Note: The databasename entry in hibernate.cfg.xml indicates the database (e.g.: MYSQL, ORACLE) used by the Web NMS server.

 

Configurable Parameters

 

The following database specific parameters can be configured using this file:

How to configure database location and data source name?

 

The location of the database can be configured using the connection.url property in hibernate.cfg.xml file. By default, the database location is set as "localhost". You can also enter the IP address or the DNS name of the machine in which the database server is running. 

 

The database for Web NMS has the data source name as "WebNmsDb", by default.

 

The table below explains the syntax:

 

Database Type

url Syntax

Example

MySQL

jdbc:mysql://hostname/data source name

jdbc:mysql://localhost/WebNmsDB

Oracle

jdbc:oracle:thin:@host_name:port_number:connect_string

jdbc:oracle:thin:@localhost:1521:orcl

Sybase ASA

jdbc:sybase:Tds:host_name:port_number/data source name

jdbc:sybase:Tds:localhost:2638/WebNmsDB

PostgreSQL

jdbc:postgresql://hostname/data source name

jdbc:postgresql://localhost/WebNmsDB

MSSQL

jdbc:sqlserver://host_name:port_number;databaseName=<databasename>

jdbc:sqlserver://localhost:1433;databaseName=WebNmsDB

 

Comment: Oracle port_number:connect_string

 

1521 is the default Oracle database port number, orcl is the Oracle database connect string.

 

 

 

Note: This URL location is specific to database server and not to the Web NMS Server. The database server and Web NMS Server can run in separate machines.

 

TOP

How to configure the database driver?

 

The JDBC driver class file for the database application used can be set against the connection.driver_class property in this file.

 

Database Type drivername Syntax

MySQL

com.mysql.jdbc.Driver

Oracle

oracle.jdbc.driver.OracleDriver

Sybase

com.sybase.jdbc3.jdbc.SybDriver

PostgreSQL

org.postgresql.Driver

MSSQL

com.microsoft.sqlserver.jdbc.SQLServerDriver

 

You can have any JDBC compatible JDBC driver name of your choice. Ensure that you have configured the class path set the same in setEnv.bat/.sh located in <Web NMS Home> directory.

 

Example

 

set DB_CLASSPATH=D:\DBTool\classes12.zip

 

TOP

How to configure database user name and password?

 

User name and password are parameters required to login to the database. These parameters need to be configured only if applicable and can be done so using the connection.username and connection.password properties in the hibernate.cfg.xml file for the chosen database.

 

By default, the user name is 'root' and password not needed for MySQL database. 'scott' and 'tiger' are Oracle's default user name and password. 

 

An example for Oracle is given below:

These parameters are used by the Server to connect to the database, if there are any problems the Server will not startup.

 

Note: For MySQL the blank password parameter is kept by default.

 

TOP

How to encrypt the database password?

 

If required, the database password specified in hibernate.cfg.xml file can be encrypted for security reasons. For getting a password in the encrypted form, please follow the steps stated below:

 

Step 1

 

Execute EncryptPassword.sh/bat file present under <Web NMS Home>/bin/admintools with the following parameters:

 

EncryptPassword.sh/bat username password encryptpassword

 

where,

Step 2

 

The password in the encrypted form will be displayed on the screen. For example, if you want the encrypted form for the password 'tiger' the same will be displayed as: Encrypted Password for password "tiger" is: eK6q2X8.

 

Copy that encrypted password.

 

Step 3

Note:

  • The Web NMS Server need not be running when executing this file.

  • Only authorized Web NMS users can change the password to the database.

 

TOP

 

How to configure the database dialect?

 

The dialect for the database application used can be set against the dialect property in this file.

 

Database Type drivername Syntax

MySQL

org.hibernate.dialect.MySQL5InnoDBDialect

Oracle

org.hibernate.dialect.Oracle10gDialect

Sybase

org.hibernate.dialect.SybaseAnywhereDialect

PostgreSQL

org.hibernate.dialect.PostgreSQLDialect

MSSQL

org.hibernate.dialect.SQLServerDialect

 

TOP

 

How to configure the database schema name?

 

The schema name for the database application used can be set against the connection.schemaname property in this file.

 

Database Type schemaname Syntax

MySQL

-

Oracle

scott

Sybase

-

PostgreSQL

public

MSSQL

-

 

How to configure the default schema name?

 

The schema name for the database application used can be set against the hibernate.default_schema property in this file.

 

Database Type schemaname Syntax

MySQL

-

Oracle

<userName>

Sybase

-

PostgreSQL

<userName>

MSSQL

-

 

TOP

How to configure the connection and statement pooling in Hibernate?

 

In Hibernate, the transaction mode is always enabled. In Web NMS with Hibernate persistence service.

For more details, please refer to the c3p0 documentation.

 

TOP

 



Copyright © 2009 ZOHO Corp. All Rights Reserved.