简体   繁体   中英

Can't connec to Mariadb from Java Netbeans

I'm having a problem connecting my from Java in Netbeans with mariadb in localhost. I've been seeing some post like this Connect to MariaDB from Java application in NetBeans on Linux (Mageia) but doesn't work it's pretty similar so I don't know why this post can't help me.

public BD(String servidor, String database, String usuario, String password) throws SQLException{
    try {


        Class.forName("org.mariadb.jdbc.Driver");
        url="jdbc:mysql://localhost/ddsi";
        conexion=DriverManager.getConnection(url, usuario, password);

        System.out.println("Conexion a Base de Datos "+url+" . . . . .Ok");

    }
    catch (ClassNotFoundException ex) {
        System.out.println(ex);
    }
}

As in the previous link I've tried everything. I also have mariadb library. 在此处输入图片说明

I checked skip-networking directive in /etc/my.cnf but it is already commented.

You have a sources JAR in your classpath, that won't work. Get a regular JAR mariadb-java-client.jar and put it on the classpath. Better yet use a dependency management tool like gradle or Maven.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM