Today I started to work with connecting databases to java and without much knowledge I started to work with a few tools I found in the internet. My programms are eclipse and MYSQL. I already got the MYSQL-App and created a new java-programm which builds the SQL-Plugin. When I try to use some databases in Java, there is an error which says
"No suitable driver found for jdbc:mysql://localhost:3306/world".
World ist a "demo-database" from MYSQL. When I open the MYSQL-Workbench it already says hat there is a Server running on my PC. As you can see my "url" is "jdbc:mysql://localhost:3306/world". I already tried a few different URLs and other things. I think there could be a problem with my Code (wrong URL...), I messed up starting a server or I built the external jar wrong.
To conclude my question is: How should I choose my URL to connect the Database stored on MYSQL-localserver? Or are there any other possibilities to use my database in java?
This is my actual code:
package pack1;
import java.sql.*;
public class Main {
public static void main(String[] args) {
String url = "jdbc:mysql://localhost:3306/world";
String user = "root";
String password = "";
try (Connection conn = DriverManager.getConnection(url, user, password)) {
System.out.println("Success");
} catch (SQLException ex) {
System.err.println(ex.getMessage());
}
}
}