0

I have a maven project where I import the mariadb driver directly from a jar file. I'm making a .jar artifact from this project using IntelliJ IDEA. I'm repeatedly getting a java.sql.SQLException: No suitable driver found for jdbc:mariadb://ip:3306/db error. What changes should I make to my project/setup to make DriverManager recognize the mariadb driver?

pom.xml

<dependency>
  <groupId>org.mariadb.jdbc</groupId>
  <artifactId>mariadb-java-client</artifactId>
  <version>2.7.4</version>
</dependency>

code (note it's not the connection string - I replaced the info)

package com.bremea.packagename.utils;

import java.sql.*;

public class db {

    private static Connection connection = null;

    public static void init() {
        try {
            connection = DriverManager.getConnection("jdbc:mariadb://ip:3306/db", "uname", "pass");
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
BreMea
  • 85
  • 2
  • 6

2 Answers2

0

Easily way to include a JDBC driver in your project.

  1. Download connector here.
  2. Copy the file into your project -> lib folder.
  3. Try to compile a code.
TheVitik
  • 11
  • 3
0

Did you reload project? Right click over the file pom.xml and select reload project, maybe the dependency does not was downloaded

Alvaro Gili
  • 25
  • 1
  • 3