Answer the question
In order to leave comments, you need to log in
How to connect MySQL driver to a project in IDEA?
In general, I'm trying to connect to the MySQL database through the program code:
program code
packagecom.company;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
public class Main {
public static void main(String[] args) throws SQLException {
sql_class.sql_query();
}
}
class sql_class{
public static void sql_query() throws SQLException {
Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/testphones","admin", "admin");
Statement st = cn.createStatement();
}
}
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/testphones
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager. getConnection(DriverManager.java:247)
at com.company.sql_class.sql_query(Main.java:16)
at com.company.Main.main(Main.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com. intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question