Drivers Tomcat

  1. Driving To Catskill
  2. Tomcat Drivers Jdbc

The Microsoft JDBC Driver 6.2 for SQL Server provides mssql-jdbc-6.2.2.jre7.jar, and mssql-jdbc-6.2.2.jre8.jar class library files. The Microsoft JDBC Drivers 6.0 and 4.2 for SQL Server provide sqljdbc41.jar, and sqljdbc42.jar class library files. The Microsoft JDBC Driver 4.1 for SQL Server provides the sqljdbc41.jar class library file. The 'Build Number' indicates the date the driver was compiled and can be used to determine the drivers age. The build number naming convention is sYYMMDD, where YY is the year, MM is the month, and DD is the day. JDK/JRE 1.8 support first included with JDBC drivers bundled with v10.5 FP7.

In this article we add MariaDB (MySQL) to our Tomcat Ubuntu 18.04 LTS server in AWS EC2. I cover the basics of how to integrate it with your Tomcat web applications. If you’ve been playing along at home, you know this is part 4 of a series that started here.


Installing MariaDB in Ubuntu is a bit of a doddle if you use the Ubuntu package manager. Life’s too short to make harder work of it, unless you really need to.

Add the JDBC driver to Tomcat The first step is to add the JDBC driver in the Tomcat lib folder. This folder is located in the Atlassian installation directory. On Linux, the default installation directory is /opt/atlassian/jira the lib folder is /opt/atlassian/jira/application/lib. The Tomcat Connection pool is configured as a resource described in The Tomcat JDBC documentation with the only difference being that you have to specify the factory attribute and set the value to org.apache.tomcat.jdbc.pool.DataSourceFactory. For, it is configured in the context.xml file of the web application: Production.

This installs it to /var/lib/mysql

You can check the version using the following command.

Secure The Installation

The mysql_secure_installation script is a thing of wonder and beauty. Run it, pay attention to what it’s telling you, accept all defaults, and set a root password you won’t forget.

Create Users & Databases

Start the mysql client using the root user, and the password created in the last step.

Execute commands similar to the following to create a database user or users, and databases that can be managed by that user. In my case, a single database named foobar that is managed by user foobaruser.

Create Data

Drivers Tomcat

You can obviously then create data as you see fit, or import data that has been exported from other databases. In my case I make one table, named foobar_stuff, with just one column and one row, containing an integer value of 42.

Integration With Tomcat

With the most minimal database in place, I now make the most minimal Tomcat web application that uses it. Being so minimal, it’s just a single JavaServer Page (JSP) with no Java Servlets or other Java code.

Web App Structure

The Tomcat web application we are about to create has just 5 files in 3 directories, and is deployed as the ROOT web application.


The context.xml file can be used to define a data source for a web application. In this case I give the data source a name of jdbc/foobar and it refers to the MariaDB SQL foobar database we created earlier. The web application will access the foobar database using the credentials we created in this post and the org.mariadb.jdbc.Driver will be the JDBC driver used.

Refer to Tomcat’s documentation for more information on JDBC Data Sources:


Driving to catskill

I require 3 libraries for this miniature web application.

javax.servlet.jsp.jstl-api.jarJavaServer Pages Standard Tag Library (JSTL) API
javax.servlet.jsp.jstl.jarJavaServer Pages Standard Tag Library (JSTL) Core
mariadb-java-client-2.4.0.jarMariaDB JDBC Driver (org.mariadb.jdbc.Driver)

The JSTL libraries are because I want to use a few JSTL tags in my JSP. The MariaDB JDBC Driver is needed for the JDBC Data Source defined in context.xml.

JSP File

I define an index.jsp file. By using that name, it is served automatically as the base document so that no URI is needed in the request.

The JSP file uses the defined Data Source to access the foobar_stuff table and display the value contained in its sole cell. JSTL tags are used to connect to the data source, and display the value.

And here’s the final result!

Security Hardening

There are of course various security hardening guides on the web. For example:

If you installed MariaDB from Ubuntu’s repositories as I described, and ran the mysql_secure_installation script, then you have already satisfied most of the common tips. Here I comment on a few others of particular interest.

Driving To Catskill

Port 3306

It’s often recommended to change the default TCP port of 3306. However, in this series, we are building an AWS server in which MariaDB is intended to be accessed only by the Tomcat instance running on the same server. The AWS Security Group we created in part 1 did not open port 3306, and hence there is no possibility for that port to be accessed by any other server. Thus I leave the default alone.


As we intend for MariaDB to only be used by Tomcat on the same server, TLS is also of no interest.

Shell History

Tomcat Drivers Jdbc

If you’ve followed my steps, your server has just the ubuntu user for server administration. This user can only login with a PEM file, thus preventing brute force password attacks. And your AWS Security Group should whitelist your IP address as the only one that can access the SSH port. Thus, no-one but you, is ever going to see the MySQL shell history. In other words, there’s no need to disable the shell history