N
N
Neonoviiwolf2016-08-10 00:24:11
MySQL
Neonoviiwolf, 2016-08-10 00:24:11

How to correctly write mysql url in java?

Good!
The first experiments with the work of the database, I watch lessons from devkolibri, they create a maven project and connect it to the database. I have a small project on javaFX, but there are no class differences between classes for working with the database, but there is no maven, respectively. + They used to download using pom.
So I downloaded mysql, installed everything and everything, added it to the library, but I can’t connect anyway, I’m sure that I’m just writing the wrong url, because I don’t understand how to write it correctly.

private static String URL = "jbdc:mysql://localhost:3306/mydbtest";
    private static String name = "root";
    private static String pass = "root";

    public static void main(String[] args) {

        Connection connection;
        try {
            Driver driver = new FabricMySQLDriver();
            DriverManager.registerDriver(driver);
            connection = DriverManager.getConnection(URL, name,pass);

        } catch (SQLException e) {
            e.printStackTrace();
        }

        launch(args);
    }

971f808211d34675a0da33ea6c9d4a7f.pngb1e0f6edd6744698a43198939d628936.png
java.sql.SQLException: No suitable driver found for jbdc:mysql://localhost:3306/mydbtest
  at java.sql.DriverManager.getConnection(DriverManager.java:689)
  at java.sql.DriverManager.getConnection(DriverManager.java:247)
  at sample.Main.main(Main.java:66)
  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:498)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Kosarev, 2016-08-10
@Neonoviiwolf

Um, not j bd c://, but j db c://

R
Rou1997, 2016-08-10
@Rou1997

The URL is absolutely correct if the port is 3306, there is a mydbtest database, and the user and password are correct, it is not clear why you are guessing on coffee grounds if there is an Exception.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question