Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Tomcat uses its context.xml file to create database connection pools and to find the database. Shrine-setup.zip contains a sample context.xml file. Copy that file to /opt/shrine/tomcat/conf and modify it as needed.

Here's an example of a context.xml file for a local mariaDB:

/opt/shrine/tomcat/conf
<?xml version='1.0' encoding='utf-8'?>
<!-- The contents of this file will be loaded for each web application -->

<Context>
    <WatchedResource>WEB-INF/web.xml</WatchedResource>
    <Resource name="jdbc/problemDB" auth="Container" type="javax.sql.DataSource"
              maxTotal="128" maxIdle="32" maxWaitMillis="10000"
              username="shrine" password="demouser" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/shrine_query_history?serverTimezone=UTC"
              testOnBorrow="true" validationQuery="SELECT 1" />

    <Resource name="jdbc/shrineDB" auth="Container" type="javax.sql.DataSource"
              maxTotal="128" maxIdle="32" maxWaitMillis="10000"
              username="shrine" password="demouser" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/shrine_query_history?serverTimezone=UTC"
              testOnBorrow="true" validationQuery="SELECT 1" />

    <Resource name="jdbc/adapterAuditDB" auth="Container" type="javax.sql.DataSource"
              maxTotal="128" maxIdle="32" maxWaitMillis="10000"
              username="shrine" password="demouser" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/adapterAuditDB?serverTimezone=UTC"
              testOnBorrow="true" validationQuery="SELECT 1" />

    <Resource name="jdbc/qepAuditDB" auth="Container" type="javax.sql.DataSource"
              maxTotal="512" maxIdle="32" maxWaitMillis="10000"
              username="shrine" password="demouser" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/qepAuditDB?serverTimezone=UTC"
              testOnBorrow="true" validationQuery="SELECT 1" />

    <Resource name="jdbc/stewardDB" auth="Container" type="javax.sql.DataSource"
              maxTotal="128" maxIdle="32" maxWaitMillis="10000"
              username="shrine" password="demouser" driverClassName="com.mysql.jdbc.Driver"
              url="jdbc:mysql://localhost:3306/stewardDB?serverTimezone=UTC"
              testOnBorrow="true" validationQuery="SELECT 1" />
</Context>

For MariaDB you will need to use an appropriate driver. In our tests, we have had success with the MySQL Connector/J driver from https://mvnrepository.com/artifact/mysql/mysql-connector-java. The jar file we used was mysql-connector-java-8.0.17.jar.  It should be installed under /opt/shrine/tomcat/lib.

MS SQL Server

For MS SQL Server, you will need to use an appropriate driver and url for your database. In our tests, we have had success with the JTS driver from https://sourceforge.net/projects/jtds/files/. The jar file we used was jtds-1.3.1.jar. It should be installed under /opt/shrine/tomcat/lib.

driverClassName="net.sourceforge.jtds.jdbc.Driver"

The URL we use looks like this:

url="jdbc:jtds:sqlserver://mssql.abcdefghijkl.us-east-1.rds.amazonaws.com:1433/adapterAuditD

Oracle

For Oracle, you will need to use an appropriate driver and url for your database. The driver must support JDK 11 and later. We test internally with ojdbc10.jar and recommend using that version.  ojdbc8.jar is also certified by Oracle to work with JDK 11.

The driver should be installed under /opt/shrine/tomcat/lib, and the following driver name should be used for all Oracle connections in context.xml:

driverClassName="oracle.jdbc.OracleDriver"

The URL we use looks like this:

url="jdbc:oracle:thin:@oracle.abcdefghijkl.us-east-1.rds.amazonaws.com:1521:SHRINEDB"

We also changed the validationQuery:

validationQuery="SELECT 1 FROM DUAL"


For Oracle, you will need to use an appropriate driver and url for your database. The driver must support JDK 11 and later. We test internally with ojdbc10.jar and recommend using that version.  ojdbc8.jar is also certified by Oracle to work with JDK 11

  • No labels