Configure Database Connection
Before SICS Batch Server can be deployed to Tomcat, the database connection must be configured.
There are two alternative modes for configuring connection from SICS Batch Server to the database:
- Application managed database connection
- Container managed database connection
Specific details used by the container managed will be covered first.
Container managed database connection #
The Container managed connection configuration is a widespread best practice for database access in Java web applications. In short, the SICS Batch Server web application declares that it requires a database connection, while the servlet container provides the actual connection.
The actual infrastructure components and configuration parameters are controlled by the application container. Java Naming and Directory Interface (JNDI) technology is used to provide the required services at runtime. There are a number of reasons why this approach is recommended:
- Database configuration is detached from the SICS Batch Server web application
- Standard tools such as the web based administration console of some servlet containers may be used to manage the configuration.
- The servlet container may monitor and share resources intelligently among the installed web applications Some SICS specific functionality is however not supported for container managed database connections.
- The database user which SICS Batch Server runs as should not require either of:
- OS authentication
- Two-level login (please see Appendix A)
If any of these limitations are unacceptable, use application managed (traditional) database connection instead. See section “Application managed database connection” below to use this approach instead.
Copy Libraries to Tomcat #
The instructions in the remainder of this section apply to Tomcat. For other servlet containers please refer to documentation regarding configuration of JNDI DataSource.
SICS supports Microsoft SQL Server, Oracle and PostgreSQL. The databases are accessed using JDBC. Tomcat doesn’t support these databases out of the box and you need to copy the necessary jar files from SICS Batch Server\jdbc\ to the %CATALINA_HOME%/lib folder:
| DBMS | JDBC Driver |
|---|---|
| Microsoft SQL Server | mssql-jdbc-12.10.2.jre11.jar |
| Oracle | ojdbc10-19.30.0.0.jar |
| PostgreSQL | postgresql-42.7.10.jar |
Set up the JDBC Connection Properties #
Open META-INF/context.xml inside sbs.war in a text editor.
The entries in this file are examples of valid connections to databases in the DXC environment. The context.xml is Tomcat specific and loaded together with the web application. It is also possible to specify the resource in a higher scope such as %CATALINA_HOME%/conf/server.xml which applies to the entire servlet container.
Make changes as follows:
- If you use Microsoft SQL Server uncomment the
<Resource>element withdriverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"and comment out the other<Resource>elements if necessary. - If you use Oracle uncomment the
<Resource>element withdriverClassName="oracle.jdbc.OracleDriver"and comment out the other<Resource>elements if necessary. - If you use PostgreSQL uncomment the
<Resource>element withdriverClassName="org.postgresql.Driver"and comment out the other<Resource>elements if necessary. - Set the correct url, username and password for your database. Note that the username and password is case-sensitive so you have to ensure the username and password are correct with respect to case.
- Tomcat 10.x uses the DBCP2 database connection pool It has a default maximum of 8 database connections. If more are needed, it must be specified on the
<Resource>element using attributemaxTotal. The value-1means “unlimited”. (For details, see https://commons.apache.org/proper/commons-dbcp/configuration.html)
You may test the connection with a SICS Workstation or System Administration Utility first. Refer to the installation documentation on how to set up database connection. The <dataSource> element in sics-database-sources.xml corresponds to the url attribute in context.xml.