I'm having a problem connecting my javafx program to my MySQL database. I'm trying to connect an actual program I'm making, but started out trying to connect with basically a blank program that only connects to the database and prints whats there so at least I know my connections good. I'm using intellij and mysql workbench. I just deleted all mysql stuff from my laptop and reinstalled it. I ran into problems there, but learned how to delete it correctly and reinstall it. It's my very uneducated option that the db isn't connecting because of my mysql connector j. I forget what downloaded what because its been so long but I think the mysql I just downloaded is version 8.0.20 but my program only accepts 6.0.5. Here are various images and code snippets. ***I changed one thing in my code and am now connected!!!*** Ok, so as I was writing this, I changed something and am now connected. It looks like I'm mixing the two versions of connector j tho. 

```
sample.fxml
<?import javafx.scene.control.Button?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane fx:controller="sample.Controller" xmlns:fx="http://javafx.com/fxml">
  <center>
    <Button text="Test Database" onAction="#testDBConnection"/>
  </center>
</BorderPane>`

```

> 
> ConnectionUtil
> 
> 
> 

```
package sample;
import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectionUtil {

  public static Connection conDB(){
    try {
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/quizdb?useSSL=false", "root", "hockey");
        System.out.println("Connected");
        return con;
    } catch (Exception ex) {
        System.out.println("no connection");
        return null;
    }
  }

}

```

> 
> Controller
> 
> 
> 

```
package sample;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Controller {

Connection con = ConnectionUtil.conDB();
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;

  public void testDBConnection(){
    String sql = "select * from question";

    try {
        preparedStatement = con.prepareStatement(sql);
        resultSet = preparedStatement.executeQuery();
        if(!resultSet.next()){
            System.out.println("End of questions");
        } else {
            int questionId = Integer.parseInt(resultSet.getObject("id").toString());
            String question = resultSet.getObject("question").toString();
            String correctAnswer = resultSet.getObject("correctAnswer").toString();
            System.out.println("Question# " + questionId + "\nQuestion: " + question + "\nCorrect Answer: " + correctAnswer);

        }
    } catch (SQLException throwables) {
        throwables.printStackTrace();
    }

  }

}

```

> 
> pom.xml
> 
> 
> 

```
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>kruzel.rob</groupId>
<artifactId>TestConnection</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.5</version>
    </dependency>

</dependencies>

</project>

```

Here are pictures of my mysql db, project structure, external libraries, etc. 

[database instance](https://i.stack.imgur.com/KP3hO.png)

[what the db tables look like](https://i.stack.imgur.com/aqZoq.png)

[external libraries/project structure](https://i.stack.imgur.com/HZaL8.png)

So I guess my question now is why in the pom.xml version do I need to have 6.0.5 but my external libraries link to 8.0.20? They originally linked to 6.0.5 but I couldn't get a connection so I downloaded the 8.0.20 jar and source.jar and added them. I know the connection is finally working but would like to understand what's going on here. Thanks in advance for any help!!