Comments - JDBC driver configuration error

7 years, 11 months ago Diego Dupin

Hi,

This is a classpath issue :

Example with a small java file :

import java.sql.Connection;
import java.sql.DriverManager;

public class Test {
    public static void main(String[] args) {
        System.out.println("init");
        try {
            try (Connection con = DriverManager.getConnection("jdbc:mariadb://localhost:3306/testj?user=diego2&password=diego")){
                System.out.println("connected");
            }
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}

On windows (on unix just replace the ";" with ":" on classpath)

c:\temp>"C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -cp "." Test
init
java.sql.SQLException: No suitable driver found for jdbc:mariadb://localhost:3306/testj?user=diego2&password=diego
        at java.sql.DriverManager.getConnection(DriverManager.java:689)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at Test.main(Test.java:8)

c:\temp>"C:\Program Files\Java\jdk1.8.0_60\bin\java.exe" -cp "./mariadb-java-client-1.4.4.jar;." Test
init
connected
 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.