简体   繁体   中英

java.lang.ClassNotFoundException: com.jdbc.mysql.Driver - Java

so I've been learning to use conections with mysql using JDBC API, but keep on getting the same error,

java.lang.ClassNotFoundException: com.jdbc.mysql.Driver

here's my code :

package modelo;

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

import javax.swing.JOptionPane;

public class ConectorBaseDatos {

Class<Connection> clase;
Connection conn;

private String host = "jdbc:mysql:3306//localhost/fifa";
private String user = "root";
public String class_directory = "com.jdbc.mysql.Driver";
private String password = "";
ResultSet result;

public ConectorBaseDatos() {

    try {

        Class.forName(class_directory);


        conn = DriverManager.getConnection(host, user, password);

        JOptionPane.showMessageDialog(null, "Conección establecida con: "
                + conn.getClass());

    } catch (Exception ex) {

        ex.printStackTrace();
        JOptionPane.showMessageDialog(null, "Error en conección: \n " + ex);

    }

}

public static void main(String[] args) {

    new ConectorBaseDatos();
}

}

I have allready imported and added the mysql-connecor.jar as referenced libraries, and just don't know where to go from here, please help.

Referenced libraries are an IDE concept that the VM has no clue about. So you'll need to run your stuff as java -cp mysql.jar:. modelo.ConectorBaseDatos java -cp mysql.jar:. modelo.ConectorBaseDatos -- if you need further assistance, leave a comment.

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