连接mysql的问题。未找到合适的驱动程序,并与用户``@'localhost'的Access拒绝访问(使用密码:是)

时间:2019-03-08 00:09:53

标签: java mysql mysql-connector

MySQL版本8.0.15
MySQL-连接器-Java-8.0.15

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.sql.*;

public class Main extends Application {

public static void main(String[] args) throws Exception {

    Statement statement = null;
    Connection connection = null;
    ResultSet resultSet = null;


    try {
        connection =
                DriverManager.getConnection("jdbc:mysql://localhost/firma?" +
                        "user=root&password=database123");

    } catch (SQLException ex) {
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
    }

    launch(args);
}

我正在寻找解决方案,并且已经为之奋斗了几个小时。 Reinstal已经完成。 交替出现一些错误。当我不将jara添加到库中时,我得到了:

SQLException:没有找到适合jdbc的驱动程序:mysql:// localhost / firma?user = root&password = database123 SQL状态:08001 VendorError:0

添加jar之后:

SQLException:服务器时区值'rodkowoeuropejski czas stand'无法识别或代表多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更特定的时区值。 SQL状态:01S00 VendorError:0

我是否将URL修改为这样的字符,因为在其他情况下,我有相同的错误How can i fix the problem with timezone and SSL

DriverManager.getConnection("jdbc:mysql://localhost/firma?useLegacyDatetimeCode=false&serverTimezone=UTC?" +
                        "user=root&password=database123");

最后我收到:

SQLException:用户'@'localhost'的访问被拒绝(使用密码:是) SQL状态:28000 VendorError:1045

为什么他甚至不在这里显示用户名?
用户“ @'localhost”的访问被拒绝(使用密码:是)

数据库存在,URL中的用户名和密码正确。

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

从控制台,我可以毫无问题地登录mysql。

请帮帮我。我的手已经掉下来了...

0 个答案:

没有答案