Bootstrap FreeKB - Tomcat - Install JDBC connector
Tomcat - Install JDBC connector

Updated:   |  Tomcat articles

A Tomcat application server will used a JDBC JAR file to make a connection to a database. There are many different JAR files that could be used, such as:

  • mysql-connector-java-version-bin.jar
  • com.springsource.org.apache.tomcat.jdbc.jar
  • mariadb-java-client-1.1.3.jar

 


Download the JAR file

Often, the JAR file is not include when Tomcat is installed, thus you will need to download the JAR file. Here are a couple example URLs that would be used to download the JAR file.

 


JAR file location on Tomcat (Linux)

There are various places where the JAR file can be place, most commonly:

  • In the Tomcat "lib" directory, such as /opt/tomcat/lib
  • In an applications "WEB-INF/lib" directory, such as /opt/tomcat/profiles/applicationserver001/webapps/app001/WEB-INF/lib

 


JAR file setup on Linux

If the JAR file is a gzip compressed tar archive. Gunzip the tar archive.

gunzip mysql-<version>.tar.gz

 

Extract the tar archive.

tar -xf mysql-<version>.tar

 

Copy the JAR file into the directory where you want the JAR file to reside.

cp mysql-connector-java-version-bin.jar /opt/tomcat/lib/

 

Add the MySQL JAR to your classpath.

export CLASSPATH=/opt/jdbc/mysql-connector-java-version-bin.jar:$CLASSPATH

 


Windows

Extract the MySQL connector zip. Move the MySQL JAR into the appropriate directory of the application server that will be used to run your Java project. For example, if your Java project will be run using Tomcat, you would copy the MySQL JAR to the $tomcat_home/lib directory.




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 0c53b7 in the box below so that we can be sure you are a human.