# Configure the Project

Add the MySQL driver, commons-dbcp2 and spring-jdbc dependencies to a Maven project's pom.xml so your Java code can work with a MySQL database.

Journeyman · Java · SQL · Updated November 16, 2026

By Gregor Dzierzon

To work with a database, the Java Maven project needs a few dependencies, which are added in the `pom.xml` file.

The pom.xml file configures your Maven projects. One section defines external dependencies.

```xml
<project ...>

    <!-- project name and version -->

    <dependencies>
        <!-- dependencies added here -->
    </dependencies>

</project>
```

We will use the `pom.xml` file to import the following dependencies.

## MySQL Driver

The MySQL driver is a Java library that is required to connect to a MySQL database. NOTE: Each database engine provides a driver that is used to connect to that database.

```xml
<dependencies>
  <dependency>
    <groupId>com.mysql</groupId>
    <artifactId>mysql-connector-j</artifactId>
    <version>8.3.0</version>
  </dependency>
</dependencies>
```

## BasicDataSource

The `BasicDataSource` object is an object used to open and close a connection to the database. This object exists in the `commons-dbcp2` package.

```xml
<dependencies>
  <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-dbcp2</artifactId>
    <version>2.9.0</version>
  </dependency>
</dependencies>
```

## JdbcTemplate

The `JdbcTemplate` is an object used to manage the execution of SQL queries. This object exists in the `spring-jdbc` package.

```xml
<dependencies>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>5.2.6.RELEASE</version>
  </dependency>
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-test</artifactId>
    <version>5.2.6.RELEASE</version>
  </dependency>
</dependencies>
```

## Cheat sheets

- [Configure the Project](https://www.ask-codey.com/cheat-sheets/configure-the-project-cheat-sheet)

Source: https://www.ask-codey.com/lessons/configure-the-project
