0
votes

I'm encountering the following error when trying to connect to the database:

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/ etc.

The MySQL connector .jar is inside the WEB-INF/lib folder

The following as been added to the pom.xml file:

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>

Any assistance / guidance would be greatly appreciated.

1

1 Answers

0
votes

Have you tried calling the driver class?:

Class.forName("com.mysql.jdbc.Driver");

an example is shown below.

try {
    Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException ex) {
    // error out
}
Connection con = DriverManager.getConnection(/*your connection query*/);