|
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:
Database location and data source name
Driver Name
User Name and Password
Dialect
Schema Name
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. |
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
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:
username scott
password tiger
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,
username - an authorized user of the Web NMS system, say root
password - the password for the above authorized user, say public
encryptpassword - the database password that has to be encrypted
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
Add the connection.encryptedpassword property of <Web NMS Home>/classes/hbnlib/hibernate.cfg.xml file, and add the encrypted password.
Ensure that the connection.password
property with no values is present in the <Web NMS Home>/classes/hbnlib/hibernate.cfg.xml.
|
|
<property name="connection.password"></property>
The above entry must be present below the connection.encryptedpassword property entry in the file.
|
Now that the database password appears in the encrypted form, you may proceed with operations as usual.
|
|
Note:
|
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 |
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 |
- |
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.
The number of non transaction connections will be configured using the nontransaction.connection property in the file. The default value is 3. This is a Web NMS specific parameter.
The minimum number of Connections a pool will create at server startup can be configured using the hibernate.c3p0.min_size property in this file. The default value is 6.
The maximum number of Connections a pool will maintain at any given time can be configured using the hibernate.c3p0.max_size property in this file. The default value is 15. The number of transaction connections that is available will be max_size - nontransaction.connection.
The size of PreparedStatement cached per connection can be configured using the c3p0.maxStatementsPerConnection property in the c3p0.properties file located in <Web NMS Home>\classes\hbnlib\. The default value is 250.
For more details, please refer to the c3p0 documentation.
|