Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
Introduction

The Hibernate configuration files are the Database access layer is used for database access and therefore requires configuration files. The database information like database usersaccess information such as accounts, passwords , and jdbc JDBC URLs etc. are specified in the hibernate configuration files. These files configuration files can be used at the time of installation of JOC Cockpit and JobScheduler Master or they can be created later on for individual jobs, e.g. the using of the ManagedDatabaseJobJSAdapterClass job.The Hibernate configuration files used by the installation are:the Job JobSchedulerManagedDatabaseJobSOSHibernate.

Generally it is preferable not to use passwords to access a database but to use Integrated Security, Oracle Wallet etc. However, should there be a need to specify passwords then instead of using a plain text password in a configuration file you can add your password to a Credential Store and add a reference to the credential store to your Hibernate configuration file. 

  • The following hibernate configuration files are available with JobScheduler Master and JOC Cockpit:
    • JobScheduler Master:
        JobScheduler run
        • Run-time database: hibernate.cfg.xml
        for JobScheduler and jobscheduler
        • Reporting database: reporting.hibernate.cfg.xml 
      • for JOC Cockpit:
        • JobScheduler run-time database: jobscheduler.hibernate.cfg.xml
        • Reporting database: reporting.hibernate.cfg.xml 

    • Database accounts, passwords, and URLs are specified as plain text with the above hibernate Hibernate configuration files when they are provided at the time of installation using the option <entry key="databaseConfigurationMethod" value="withoutHibernateFile"/>. To make the hibernate configuration file to use the database information access data from the Credential Store it is required to first create the hibernate configuration files file and then use the <entry key="databaseConfigurationMethod" value="withHibernateFile"/> at the time of installation and provide the path to the Hibernate configurations fileconfiguration file.
    • The Hibernate configuration file also supports the Credential Store. 
      Display feature availability
      StartingFromRelease1.13.3

      Display feature availability
      StartingFromRelease1.12.12

    Create a custom hibernate Hibernate file which accesses the Database accounts, password, and URL from the Credential Store.

    Parameter String to retrieve the data from Credential Store

    The SOSKeePassDatabase the class uses a parameter string that holds a URI and a number of query parameters:

    URI

    cs://<entry_path>@<property_name> - required 

    • The URI based syntax includes the protocol cs:// 
    • followed by the <entry_path> that specifies the directory structure and entry name in the credentials store file.
    • followed by the @ character
    • followed by the <property_name> that should be retrieved:

      • frequently-used properties include credential store field names such as title, user, password, attachment Custom field names are supported. 

    Query Parameters

    • file - required 
      the path to the credential store database file. This file can be stored anywhere in the file system.

    • password password - optional 
      the password for the credential store database file. 
      It is recommended not to use this parameter and instead to use a key_file to access the credential store.

    • key_file - optional, default: <credential_store_database_filename_without_extension>.key 

    Refer to the Knowledgebase article the  Using a Credential Store for Jobs#Syntax for  article for a detailed description.

    The syntax for Hibernate Configuration files

    The hibernate Hibernate configuration file is introduced with different elements (property optionsproperties) which that can be used to retrieve the information from a Credential Store. It provides two types of syntax: 

    Full Syntax

    The Full syntax is used when the complete URI is to be used with each property element of the Hibernate configuration file. The following syntax can be used to retrieve the information from Credential Store: 

    • <property name="hibernate.connection.username">cs://<entry_path>@user?file=<path [path to database kdbx file><*.kdbx file]</property> 
    • <property name="hibernate.connection.password">cs://<entry_path>@password?file=<path [path to database *.kdbx file>file]</property>
    • <property name="hibernate.connection.url">cs://<entry_path>@url?file=<path [path to database *.kdbx file>file]</property>

    The [path to *.kdbx file] is a relative or absolute path to the KeePass database that holds the Credential Store.

    Short Syntax

    The Short syntax is used when the credential store items are to be used in the hibernate configuration to provide the details about the credential store:

    • <property name="hibernate.sos.credential_store_file">some/path/database.kdbx<>[path to *.kdbx file]</property> → Stores the path to the credential store file
    • <property name="hibernate.sos.credential_store_key_file">some/path/database.key<>[path to *.key file]</property> → Stores the path of the key file to open the credential store
    • <property name="hibernate.sos.credential_store_password">some password<>[some password]</property> → Stores the password of the credential store file
    • <property name="hibernate.sos.credential_store_entry_path">[/some/entry/path<path]</property> → specifies the directory structure and entry name in the credentials store file.

    After adding the credential store items in reference to the hibernate Hibernate configuration file the database information access data can be retrieved from the credential store Credential Store by using the following property elementelements

    • <property name="hibernate.connection.username">cs://@user</property> 
    • <property name="hibernate.connection.password">cs://@password</property> 
    • <property name="hibernate.connection.url">cs://@url</property>     


    Example of a hibernate Hibernate file that uses the KeePass database (*.kdbx) with Password a password to access database credentials.

    Code Block
    languagexml
    titleExample
    collapsetrue
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <hibernate-configuration>
    <session-factory>
    <property name="hibernate.connection.url"><![CDATA[cs://server/test/reporting/MySQL@url?file=config/cs/kdbx-p-f.kdbx&password=test]]></property>
    <property name="hibernate.connection.username"><![CDATA[cs://server/prod/reporting/MySQL@username?file=config/cs/kdbx-p-f.kdbx&password=test]]></property>
    <property name="hibernate.connection.password"><![CDATA[cs://server/test/reporting/MySQL@password?file=config/cs/kdbx-p-f.kdbx&password=test]]></property>
    <property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
    <property name="hibernate.show_sql">false</property>
    <property name="hibernate.connection.autocommit">false</property>
    <property name="hibernate.format_sql">true</property>
    <property name="hibernate.temp.use_jdbc_metadata_defaults">false</property>
    </session-factory>
    </hibernate-configuration>

    Explanations

    • The Hibernate file make makes use of a KeePass database (*.kdbx) for accessing Database database credentials.
    • cs://server/test/reporting/MySQL is the <entry_path> path where the MySQL database credential stores.
    • file - File path of the KeePass database (*.kdbx).
    • password- Password for accessing the KeePass database (kdbx)

    ...

    Note: If the key file name and KeePass database (kdbx) file name are the same and are at the same location, for example, KeePass database name is kdbx-p-f.kdbx and the key file name is kdbx-p-f.key and both are on the same path i.e. config/cs then it will take the key default and it is not required to mention the path to the key file.

    Downloads

    Configuring attached example

    • Unzip the archive to the live folder of JobScheduler installation 
    • Add the database configuration according to your environment in the KeePass file kdbx-p-f.kdbx.
    • To access the KeePass file use kdbx-p-f.key as a key file.
    • Make the changes for the Database (URL, Username, Password)
    • The file hibernate-cs.syntax.full.cfg.xml includes the elements to access kdbx.
    • The Databasejob includes the command (database query) to be executed
    • Run the order hibernate_order from the JOC Cockpit
    • The output of the command will be displayed

    References

    • Links to Change Management System 
      • Jira
        serverSOS JIRA
        columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
        serverId6dc67751-9d67-34cd-985b-194a8cdc9602
        keyJITL-587
      • Jira
        serverSOS JIRA
        columnskey,summary,type,created,updated,due,assignee,reporter,priority,status,resolution
        serverId6dc67751-9d67-34cd-985b-194a8cdc9602
        keyJITL-589

    ...