首页 > 解决方案 > SQLException : Access denied for user 'utilisateur1'@'localhost' (using password: YES)

问题描述

package com.exmaven2;

import java.sql.*;


public class MainApp 
{
    public static void main(String[] args) 
    {
        String url = "jdbc:mysql://localhost:3306/baseune"; 
        String userName = "utilisateur1";
        String password = "password";
        
        try { 
            java.sql.Connection con = DriverManager.getConnection(url, userName, password); 
        } catch (SQLException e) {
            e.printStackTrace();
        }   
    }
}

Hello, I'm actually trying to connect to MySQL with a Maven project build in Eclipse IDE. I wrote this code that should let me connect to my server but I'm getting the error described in the title. I just began learning about databases and MySQL so I don't really know what to do. I already checked the privileges for 'utilisateur1' (somebody else posted the same question but this answer didn't work for me) and i have them all so I don't understand why it doesn't work.

标签: javamysqljdbcsqlexception

解决方案


你能试试这个吗

package com.exmaven2;

import java.sql.*;
public class MainApp 
{
    public static void main(String[] args) 
    {
        String url = "jdbc:mysql://localhost:3306/baseune?useSSL=false"; 
        String userName = "utilisateur1";
        String password = "password";
        
        try { 
            Connection con = DriverManager.getConnection(url, userName, password); 
        } catch (SQLException e) {
            e.printStackTrace();
        }   
    }
}

推荐阅读