Introduction

  • The JOC Cockpit uses a database to store inventory information, status information and workflow related logs. The database provides restart capabilities for the JS7 - Cluster Service. The Controller and Agent do not use database connections.
  • JS7 does not include a DBMS. Instead, it uses a DBMS that is installed by the user - with the exception of H2®, an embeded version of which is included with JS7 for evaluation purposes.
  • The supported DBMS products include:
    • Embedded H2®
    • MariaDB®
    • MySQL®
    • Oracle®
    • PostgreSQL®
    • SQL Server®
  • Access to the DBMS is provided by the Hibernate database access layer. This includes use of a JDBC Driver that is specific for the DBMS.
  • Also check and apply the measures described in the JS7 - Database Maintenance article.
  • Caveat: Users of JS1 (1.x releases) should not reuse the JS1 database schema for JS7. Instead, JS7 should be installed with its own schema.

DBMS and JDBC Driver Versions

Operation of JS7 is supported for the DBMS versions listed in the table below.

JDBC Drivers for a number of DBMSs are included with JS7. However, due to restrictions placed on bundling JDBC Drivers with Open Source software for some DBMS products, users have to download the JDBC Driver from the vendor's web site themselves:

DBMS
Product
DBMS
Version
JDBC Driver
Version
JDBC Driver
File
JDBC Driver
License
Included with JS7Comment
H2®1.4.2001.4.200h2-1.4.200.jarMPL 2.0, EPL 1.0noDBMS and JDBC Drivers are Open Source
MariaDB®102.7.2mariadb-java-client-2.7.2.jarLGPLyesDBMS and JDBC Drivers are Open Source
MySQL®5.7, 8.08.xmysql-connector-java-8.x.jarProprietary Licenseno

DBMS is Open Source, JDBC Drivers are not Open Source

The MariaDB® JDBC Driver can be used for access to MySQL® databases

Oracle®12c, 18c, 19c, 21c21.8ojdbc8-19.19.0.0.jar
FUTC Licenseyes

DBMS and JDBC Drivers are not Open Source

Use ojdbc8*.jar for Java 8 and Java 11
Use ojdbc11*.jar for Java 11 and Java 17

PostgreSQL®10, 11, 12, 13, 14, 1542.4.3postgresql-42.4.3.jarBSD 2-clauseyesDBMS and JDBC Drivers are Open Source
SQL Server®2016, 2017, 20199.x, 10.x, 11.xmssql-jdbc-<version>.jre8.jar
mssql-jdbc-<version>.jre11.jar
mssql-jdbc-<version>.jre17.jar
Proprietary Licenseno

DBMS and JDBC Drivers are not Open Source
Use mssql*.jre11.jar for Java 11
    (JDBC Driver version 7.2 to 9.x)
Use mssql*.jre17.jar for Java 17
    (JDBC Driver version 10.2 and newer)


In most situations it is technically possible to operate JS7 with newer versions of a DBMS or JDBC Driver if the version is actively supported by the DBMS vendor. Users frequently ask if JS7 is compatible with newer versions of a DBMS or JDBC Driver. It's the wrong question and your DBA should know the answer. Consider the following example for Oracle® that similarly applies to other DBMSs:

  • Oracle® ships a newer version of their DBMS compatible to previous versions, e.g. the 19c release is compatible to 18c and down to 12c and 10g.
  • Compatibility includes that your DBA identifies the technical compatibility switch in the DBMS to run the 19c version compatible to 18c, 12c etc. This means your DBA is in control of compatibility.
  • SOS documents that JS7 is compatible to Oracle® 12c and 18c. This boils down to the fact that your DBA can run any newer version of the DBMS in a compatibility mode that supports 12c or 18c.
  • The question if SOS will ship a JS7 release specifically for 19c would mean that the product is no longer compatible to earlier releases of the DBMS. This will not happen. The JS7 is not too demanding when it comes to the DBMS, which is considered as a datastore.

The same applies to JDBC Drivers. There might be newer versions of JDBC Drivers that e.g. include bug-fixes. Do not ask SOS if JS7 is compatible to a specific JDBC Driver version. Ask your DBMS vendor if a newer version of the JDBC Driver is compatible to the one stated above. When picking a JDBC Driver then check compatibility with the Java version in use. For Java versions that can be used with JS7 see the Which Java versions is JobScheduler available for? article.

SOS performs >5000 regression tests when it comes to compatibility of Java, DBMS and JDBC Driver versions. The versions listed above are included in the SOS regression testing. If a specific version is not stated above then this doesn't mean that JS7 will not work with this version, it means that this version is not included with SOS regression testing. SOS supports the use of newer DBMS and JDBC Driver versions not stated above as long as users prove that they are operated in a compatibility mode that corresponds to one of the versions stated above.

Hibernate Configuration Files

  • Hibernate configuration files are used in an XML format.
  • JS7 - JOC Cockpit Installation On Premises
    • During installation the relevant hibernate configuration file is created and can be manually updated later on.
    • After installation of the JOC Cockpit the hibernate.cfg.xml Hibernate configuration file is available in
      • Unix
        • /var/sos-berlin.com/js7/joc/jetty_base/resources/joc
      • Windows
        • C:\ProgramData\sos-berlin.com\js7\joc\jetty_base\resources\joc
      • A different location for the configuration directory can be specified during installation of the JOC Cockpit.
  • JS7 - JOC Cockpit Installation for Containers
    • The JOC Cockpit ships preinstalled from a container image.
    • It is therefore recommended that users:
      • download/copy one of the Hibernate configuration files listed below to:
        • /var/sos-berlin.com/js7/joc/jetty_base/resources/joc
      • adjust changes to reflect their database connection. For use with H2® you can use the below sample without changes.
  • By default the Hikari Connection Pool is used.
  • Consider that XML requires special characters to be used with escape characters, for example a password in the Hibernate configuration file that includes the character & is written as &amp;. This applies to any values of XML elements and attributes in Hibernate configuration files.
    • Wrong: <property name="hibernate.connection.password">sec&ret</property>
    • Right: <property name="hibernate.connection.password">sec&amp;ret</property>

Hibernate Configuration for Embedded H2®

Download: hibernate.cfg.xml-h2 (drop the -h2 extension when storing the file)

Hibernate configuration file for H2® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">org.h2.Driver</property>
  <property name="hibernate.connection.password"/>
  <property name="hibernate.connection.url">jdbc:h2:./resources/joc/h2/joc</property>
  <property name="hibernate.connection.username">joc</property>
  <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • The JDBC connection URL makes use of the embedded H2® database server. The database file will be located in /var/sos-berlin.com/js7/joc/resources/joc/h2.
  • You can store the above configuration without further changes in the /var/sos-berlin.com/js7/joc/jetty_base/resources/joc directory.
  • Note that for a standalone H2® database server a syntax such as jdbc:h2:tcp://<host>:<port>/jobscheduler can be used where <host> is the hostname and <port> is the H2® database port (frequently: 1521).

Hibernate Configuration for MariaDB®

Download: hibernate.cfg.xml-mariadb (drop the -mariadb extension when storing the file)

Hibernate configuration file for MariaDB® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">org.mariadb.jdbc.Driver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:mariadb://mariadbsrv:3306/jobscheduler</property>
  <property name="hibernate.connection.username">jobscheduler</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • The example uses the MariaDB® database server running with hostname mariadbsrv and port 3306.
  • Note that the InnoDB storage engine is used as the JS7 requires a transactional DBMS.

Hibernate Configuration for MySQL®

Download: hibernate.cfg.xml-mysql (drop the -mysql extension when storing the file)

Hibernate configuration file for MySQL® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">org.mysql.jdbc.Driver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:mysql://mysqlsrv:3306/jobscheduler</property>
  <property name="hibernate.connection.username">jobscheduler</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • The example uses the MySQL® database server running with hostname mysqlsrv and port 3306.
  • The example applies to use of a MySQL® JDBC Driver. Such drivers do not ship with JS7 as they are not available from open source compatible license. Users can download such drivers from the vendor's site.
  • For use with MySQL® databases the MariaDB® JDBC Driver can be used that ships with JS7. The class name for this driver is org.mariadb.jdbc.Driver, see example for MariaDB®.

Hibernate Configuration for Oracle®

Download: hibernate.cfg.xml-oracle (drop the -oracleextension when storing the file)

Hibernate configuration file for Oracle® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:oracle:thin:@//oraclesrv:1521/xe</property>
  <property name="hibernate.connection.username">jobscheduler</property>
  <property name="hibernate.dialect">org.hibernate.dialect.Oracle12cDialect</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
  <property name="hibernate.hikari.connectionInitSql">ALTER SESSION SET NLS_COMP='LINGUISTIC'</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • The example uses the Oracle® database listener running with hostname oraclesrv and port 1521. The database Service Name is xe.
  • If you want to use a Service ID instead of a Service Name, then use the URL syntax: jdbc:oracle:thin:@oraclesrv:1521:xe
  • If you want to directly specify additional settings typically used from tnsnames.ora, then use the URL syntax: jdbc:oracle:thin:@(DESCRIPTION =(ADDRESS_LIST =(ADDRESS =(PROTOCOL=TCP)(HOST=oraclesrv)(PORT=1521)))(CONNECT_DATA=(SID=XE)(GLOBAL_NAME=XE.WORLD)(SERVER=DEDICATED)))
  • The NLS_COMP setting is specified for use with UTF databases.
  • If you want to use Oracle Wallet®, then specify empty values for the <property name="hibernate.connection.username"> and <property name="hibernate.connection.password"> elements. You will find further information in the How to connect to an Oracle database without using passwords article.


  • The JDBC Driver URL for Oracle® RAC databases can be added like this:

    jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON) 
    (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db1.example.com)(PORT=1604)) 
    (ADDRESS=(PROTOCOL=TCP)(HOST=tst-db2.example.com)(PORT=1604))) 
    (CONNECT_DATA=(SERVICE_NAME=mydb1.example.com)(SERVER=DEDICATED)))

Hibernate Configuration for PostgreSQL®

Download: hibernate.cfg.xml-postgresql (drop the -postgresql extension when storing the file)

Hibernate configuration file for PostgreSQL® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:postgresql://postgresqlsrv:5432/jobscheduler</property>
  <property name="hibernate.connection.username">jobscheduler</property>
  <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • The example uses the PostgreSQL® database server running with hostname postgresqlsrv and port 5432.

Hibernate Configuration SQL Server®

Download: hibernate.cfg.xml-sqlserver (drop the -sqlserver extension when storing the file)

Hibernate configuration file for SQL Server® database
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<hibernate-configuration>
 <session-factory>
  <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
  <property name="hibernate.connection.password">jobscheduler</property>
  <property name="hibernate.connection.url">jdbc:sqlserver://sqlserversrv:1433;sendStringParametersAsUnicode=true;selectMethod=cursor;databaseName=jobscheduler</property>
  <property name="hibernate.connection.username">jobscheduler</property>
  <property name="hibernate.dialect">org.hibernate.dialect.SQLServer2005Dialect</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>
  <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
  <property name="hibernate.hikari.maximumPoolSize">10</property>
 </session-factory>
</hibernate-configuration>

Explanation:

  • Note that the JDBC Driver for SQL Server® has to be downloaded separately as it does not ship with JS7.
  • The example uses the SQL Server® database server running with hostname sqlserversrv and port 1433.
  • Note that use of the above parameters with the JDBC URL is required: sendStringParametersAsUnicode=true;selectMethod=cursor
  • For Windows environments, access to SQL Server can be configured to use integrated security, i.e. using the account that the JOC Cockpit Windows Service is operated with. 
    • Specify empty values for the <property name="hibernate.connection.username"> and <property name="hibernate.connection.password"> elements.
    • Add to the JDBC URL: integratedSecurity=true
    • The account used for the JOC Cockpit Windows Service has to be configured with SQL Server® to allow access to the database.
    • The JDBC Driver distribution usually ships with a library for authentication purposes with a name such as sql_jdbc.dll or  mssql-jdbc_auth-9.2.1.x64.dll or similar. This library should be added to a location that is specified with the Windows PATH environment variable for the JOC Cockpit Windows Service or simply stored in the C:\Windows\System32 directory or in the bin directory of the Java JDK/JRE in use.

Database Setup

First of all, users have to create a database schema and account for JS7. The database schema has to support the Unicode character set.

The following sections provide some common examples that are neither complete and nor exhaustive. Database administrators might apply their own standards for setting up a database for JS7.

Setup for H2®

When using the JS7 - JOC Cockpit - Installation Using the Graphical Installer for Linux and Windows then the database will be created automatically.

As a prerequisite users have to download the H2 JDBC Driver, for example from http://www.h2database.com/html/download-archive.html:

  • JDBC Driver version 1.4.200 is reported to work with JS7.
  • The JDBC Driver .jar file, for example h2-1.4.200.jar
    • can be specified with the JOC Cockpit graphical installer,
    • can be added to an existing JOC Cockpit installation, see chapter Individual JDBC Driver Versions.
      • In this situation users can run the following commands
        • cd $JETTY_BASE | cd %JETTY_BASE%
        • ../install/joc_install_tables.sh | ..\joc_install_tables.cmd
      • It is required to navigate to the JETTY_BASE directory to run the above commands in order to have the database being created in ./resources/joc/h2.as specified by the H2® Hibernate configuration file.

H2® ships with a console application that by default is available for browsers from port 8082. It is not required to run the H2® console application, however, find the following information how to invoke the console application.

  • JOC Cockpit has to be stopped as the embedded H2® database can be used by a single client only.
  • The console application and the database are started by invoking the H2® .jar file like this:
    • cd $JETTY_BASE | cd %JETTY_BASE%
    • java -jar ./lib/ext/joc/h2-1.4.200.jar -webAllowOthers -tcpAllowOthers
  • It is required to navigate to the JETTY_BASE directory to run the above commands in order to have the database being created in ./resources/joc/h2.as specified by the H2® Hibernate configuration file.
  • The H2® console application should launch a browser window if executed from the local machine and otherwise will displays a URL to connect to the application.
  • For login users should specify
    • the URL: jdbc:h2:./resources/joc/h2/joc as indicated from the above Hibernate configuration file
    • the user name: joc
    • an empty password.

Setup for MariaDB®/ MySQL®

Database

For the character encoding of the database UTF8 has to be specified. Similarly a collation sequence should be specified that includes UTF8 support.

Example how to set up the database for Unicode support
# add database
CREATE DATABASE js7 CHARACTER SET utf8 COLLATE utf8_general_ci;

Account

Example how to create accounts
# add account
CREATE USER 'jobscheduler'@'%' IDENTIFIED BY 'jobscheduler';

In case that separate owner and run-time accounts are to be used for database access it is recommended that the database objects are created first using the owner account and the installation of JOC Cockpit is performed using the run-time account:

  • Connect to the database using a MariaDB® / MySQL® client and the owner account.
  • Run the mysql.sql script that is available from the db sub-directory when extracting the JOC Cockpit installer .tar.gz/.zip archive.

Permissions

The following permissions are required for the schema:

  • to manage objects
    • Tables, Views, Functions, Stored Procedures: CREATE, DROP, ALTER
  • to access objects at run-time
    • Tables, Views: SELECT, INSERT, UPDATE, DELETE
    • Functions, Stored Procedures: EXECUTE

Example how to grant permissions to accounts
# grant all permissions
GRANT ALL ON js7.* TO 'jobscheduler'@'%';

# alternatively grant individual permissions
GRANT CREATE, CREATE VIEW, DROP, ALTER, EXECUTE, SELECT, UPDATE, INSERT, DELETE on js7.* to 'jobscheduler'@'%';

Setup for Oracle®

For secure connections without use of passwords refer to the information in the JS7 - How to make JOC Cockpit connect to an Oracle database using Wallet® article.

Database

When creating the database consider using UTF based character encoding and a collating sequence that supports UTF - for example:

Example how to set up the database for Unicode support
# set up database
CREATE DATBASE JS7
...
CHARACTER SET AL32UTF8;

# consider linguistic sorting for Unicode with WHERE clauses
ALTER SESSION SET NLS_COMP='LINUGUISTIC';

# consider linguistic sorting for Unicode with ORDER BY clauses
ALTER SESSION SET NLS_SORT='LINUGUISTIC';

Note:

  • Note that NLS_COMP and NLS_SORT have to use the same value.

Accounts

Frequent practice includes setting up two accounts: an owner account that owns the schema & objects and a run-time account that is granted permissions to access objects of the owner schema. Alternatively a single account can be used that owns the schema.

Example how to create accounts
# add owner account
CREATE USER JS7_OWNER IDENTIFIED BY JS7_OWNER;
GRANT CONNECT, RESOURCE TO JS7_OWNER;

# add run-tine account
CREATE USER JS7_USER IDENTIFIED BY JS7_USER;
GRANT CONNECT, RESOURCE TO JS7_USER;

If separate owner and run-time accounts are to be used then it is recommended that the database objects are created first using the owner account and then the installation of JOC Cockpit is performed using the run-time account:

  • Connect to the database using an Oracle® client and the owner account.
  • Run the oracle.sql script that is available from the db sub-directory when extracting the JOC Cockpit installer .tar.gz/.zip archive.

Permissions

The following permissions are required for JS7:

  • Owner Account
    • Tables, Views, Sequences: CREATE, DROP, ALTER
    • Procedures: EXECUTE
  • Run-time Account
    • Tables, Views: SELECT, INSERT, UPDATE, DELETE
    • Sequences: SELECT
  • If a single account is used then all above permissions have to be assigned to this account.

There are number of ways of assigning permissions, e.g. by use of roles. One option is to create the objects in the owner schema and to generate the respective GRANT commands and CREATE SYNONYM commands for the run-time account as follows:

Example how to create GRANT commands for permissions to the run-time account
# generate SQL statement to grant permissions to run-time account
SELECT DISTINCT
       CASE
            WHEN object_type = 'SEQUENCE' THEN 'GRANT SELECT'
            WHEN object_type IN ('TABLE', 'VIEW') THEN 'GRANT SELECT,INSERT,UPDATE,DELETE'
       END
       || ' ON JS7_OWNER.'|| object_name || ' TO JS7_USER;' 
  FROM dba_objects 
 WHERE object_type IN ('TABLE','VIEW','SEQUENCE') and owner='JS7_OWNER';
Example how to create synonyms for the run-time account
# generate SQL statement to create synonyms for run-time account

SELECT 'CREATE SYNONYM ' || 'JS7_USER.' || table_name || ' FOR '|| owner || '.' || table_name ||';' FROM all_tables WHERE owner = 'JS7_OWNER';
SELECT 'CREATE SYNONYM ' || 'JS7_USER.' || view_name || ' FOR '|| owner || '.' || view_name ||';' FROM all_views WHERE owner = 'JS7_OWNER';
SELECT 'CREATE SYNONYM ' || 'JS7_USER.' || sequence_name || ' FOR '|| sequence_owner || '.' || sequence_name ||';' FROM all_sequences WHERE sequence_owner = 'JS7_OWNER';

Setup for PostgreSQL®

Database

When creating the database consider using a UTF based character encoding and collating sequence, for example:

Example how to set up a PostgreSQL database for Unicode support
# set up database
CREATE DATABASE JS7
ENCODING 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8';

Accounts

A user account is created in PostgreSQL®, for example:

Example how to create accounts in PostgreSQL
# add an account
create user JS7_USER with password 'JS7_USER';

If separate owner accounts and run-time accounts should be used for database access it is recommended to first create the database objects using the owner account and then to perform the installation of JOC Cockpit using the run-time account:

  • Connect to the database using a PostgreSQL® client and the owner account.
  • Run the pgsql.sql script that is available from the db sub-directory when extracting the JOC Cockpit installer .tar.gz/.zip archive.

Permissions

The following permissions are required for the schema:

  • to manage objects
    • Tables, Views, Functions, Stored Procedures: CREATE, DROP, ALTER
  • to access objects at run-time
    • Tables, Views: SELECT, INSERT, UPDATE, DELETE
    • Functions, Stored Procedures: EXECUTE


In PostgreSQL® a role is created that carries permissions and that is assigned to the user. The commands for creating a role and assigning it to the user are like this:

Example how to create a role, grant permissions to the role and assign the role to the user account
# create a role
create role JS7_ROLE WITH LOGIN;

# grant permissions as specified above to the role
grant USAGE on schema public to JS7_ROLE;
 
grant SELECT,UPDATE,INSERT,DELETE on all tables in schema public to JS7_ROLE;
grant EXECUTE on all functions in schema public to JS7_ROLE;
grant CREATE on schema public to JS7_ROLE;

# assign the role to the user
grant JS7_ROLE to JS7_USER;

Setup for SQL Server®

For secure connections without use of passwords refer tothe information in the JS7 - How to connect to an SQL Server database without using passwords article.

Database

When creating the database then use a UTF based character encoding and collating sequence, for example:

Example how to set up an SQL Server database for Unicode support
# set up database
CREATE DATABASE JS7
...
COLLATE LATIN1_GENERAL_100_CI_AS_SC_UTF8;

Accounts

A user account is created in SQL Server®, for example:

Example how to create accounts in SQL Server
# add an account
create user JS7_USER with password = 'JS7_USER';

If separate owner and run-time accounts are be used for database access then it is recommended that the database objects are created using the owner account and that the installation of the JOC Cockpit is then carried out using the run-time account:

  • Connect to the database using an SQL Server® client and the owner account.
  • Run the mssql.sql script which is available from the db sub-directory when extracting the JOC Cockpit installer .tar.gz/.zip archive.

Permissions

The following permissions are required for the schema:

  • to manage objects
    • Tables, Views, Functions, Stored Procedures: CREATE, DROP, ALTER
  • to access objects at run-time
    • Tables, Views: SELECT, INSERT, UPDATE, DELETE
    • Functions, Stored Procedures: EXECUTE

Connection Pool

JS7 makes use of a connection pool to allow a larger number of JOC Cockpit user sessions to share database connections from the pool.

  • By default a JOC Cockpit REST Web Service is configured to use up to 10  connections from the pool. As a rule of thumb 1 connection can be shared by approx. 3 simultaneous users.
    • Adjust this setting to the max. number of connections required for sharing between simultaneous users of the JOC Cockpit.
    • Note that connections will be disconnected and returned to the pool if they are not used for a longer time.
  • Additional connections are used by JS7 Services. Consider the total number of connections allowed when setting up your JS7 database.
    • Some DBMS products by default limit the number of connections per user account and process. JOC Cockpit is running from a single process.
    • Oracle by default limits the connections according to the formula: (1.5 * number of processes) + 22
  • When operating a JOC Cockpit cluster additional connections for the REST Web Service will be created per JOC Cockpit instance.


JOC Cockpit ComponentMin. ConnectionsMax. ConnectionsConfigurableComment
JS7 - REST Web Service API10unbounded (default: 10)yes

Recommendation: number of simultaneous users / 3.
This number counts per JOC Cockpit instance.
The Daily Plan Service uses connections from this connection pool.

JS7 - Cluster Service:

11no
JS7 - Cleanup Service5unbounded (default: 5)yesConfiguration via JS7 - Settings
JS7 - History Service1number of connected Controller InstancesnoAny Controllers connected to a JOC Cockpit Instance are counted.
JS7 - Monitor Service33no2 connections for JS7 - Monitoring.
1 connection for JS7 - Notification.

Total: 20 



Hibernate allows one out of a number of Connection Pool implementations to be chosen.

  • By default the Hikari Connection Pool is used with JS7.
    • The Hikari setting for the maximumPoolSize is included with the Hibernate configuration file as this determines the max. number of open database connections:

      Hikari Connection Pool recommended settings
        <property name="hibernate.connection.provider_class">org.hibernate.hikaricp.internal.HikariCPConnectionProvider</property>
        <property name="hibernate.hikari.maximumPoolSize">10</property>
      
    • Additional property elements can be used in a Hibernate configuration file to add further settings to the Hikari connection pool.
  • Alternatively e.g. the C3P0 Connection Pool can be used.
    • Use of C3P0 suggests a number of additional settings that better match use with JS7 than the default values:

      C3P0 Connection Pool recommended settings
        <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
        <property name="hibernate.c3p0.maxConnectionAge">14400</property>
        <property name="hibernate.c3p0.maxStatementsPerConnection">0</property>
        <property name="hibernate.c3p0.maxStatements">0</property>
        <property name="hibernate.c3p0.checkoutTimeout">0</property>
        <property name="hibernate.c3p0.maxIdleTime">14400</property>
        <property name="hibernate.c3p0.acquireRetryAttempts">1</property>
        <property name="hibernate.c3p0.minPoolSize">5</property>
        <property name="hibernate.c3p0.acquireIncrement">1</property>
        <property name="hibernate.c3p0.statementCacheNumDeferredCloseThreads">1</property>
        <property name="hibernate.c3p0.numHelperThreads">3</property>
        <property name="hibernate.c3p0.idleConnectionTestPeriod">1800</property>
        <property name="hibernate.c3p0.maxPoolSize">10</property>
        <property name="hibernate.c3p0.initialPoolSize">5</property>
    • Additional property elements can be used to add further settings. However, close reading of the C3P0 docs is recommended before applying changes.

Individual JDBC Driver Versions

If you have to use an individual version of a JDBC Driver that is not included with JS7, for example for use with SQL Server®, or if you have to use a specific version of the Oracle JDBC Driver®, then you can add the JDBC Driver to the JOC Cockpit.

  • Note that conflicting JDBC Drivers could be included with JS7. Such conflicts can originate from the fact that two JDBC Drivers use the same class name as specified with the hibernate.connection.driver_class attribute value in a Hibernate configuration file.
  • In case of conflicts remove existing JDBC Driver (*.jar) files when adding your version of a JDBC Driver.

When installing or updating the JOC Cockpit, you can specify the JDBC Driver that should be used by the installer, for details see:

The following sections explain how to add a JDBC Driver to an existing installation without updating the JOC Cockpit from the installer.

Adding a JDBC Driver to an existing Installation on premises

Find JDBC Drivers from the following locations of the JOC Cockpit configuration directory:

  • Unix
    • /var/sos-berlin.com/js7/joc/jetty_base/lib/ext/joc
  • Windows
    • C:\ProgramData\sos-berlin.com\js7\joc\jetty_base\lib\ext\joc
  • Note that a different location for the configuration directory can be specified during installation of JOC Cockpit.

From this location you will find the JDBC Driver files indicated in the above table. 

  • Add your JDBC Driver (*.jar) file to this location
  • Optionally remove existing JDBC Driver (*.jar) files from this location, for example to replace the Oracle® JDBC Driver that ships with JS7 by a newer version.

Consider applying changes to your Hibernate configuration file that reflect change of the JDBC Driver. You will find the hibernate.cfg.xml Hibernate configuration file in the JOC Cockpit configuration directory:

  • Unix
    • /var/sos-berlin.com/js7/joc/jetty_base/resources/joc
  • Windows
    • C:\ProgramData\sos-berlin.com\js7\joc\jetty_base\resources\joc
  • A different location for the configuration directory can be specified during installation of JOC Cockpit.

Restart the JOC Cockpit to apply your changes.

Adding a JDBC Driver to a Container installation

When using the JOC Cockpit container image then technically no installer is included that allows to specify the JDBC Driver to be used. Instead, images are preinstalled. In addition, there is no access to the container's file system before running the container which makes it impossible to add or replace a JDBC Driver before JOC Cockpit is started.

For use with a JOC Cockpit container you can copy the JDBC Driver to the following location:

  • /var/sos-berlin.com/js7/joc/resources/joc/lib
  • The /var/sos-berlin.com/js7/joc/resources/joc directory is typically mounted to a volume when running the container - for details see the JS7 - JOC Cockpit Installation for Containers article. If the lib sub-directory does not exist then you can create it to store the JDBC Driver (*.jar) file.

Consider applying changes to your Hibernate configuration file as described in the previous section. Then restart the JOC Cockpit container.

On startup the JOC Cockpit checks the above directory for the existence of *.jar files. If a JDBC Driver is found then:

  • the *.jar file will be copied to ./jetty_base/lib/ext/joc 
  • any existing JDBC Driver *.jar files in this directory are removed.

Further Resources

How To ... Instructions