Re: MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Posted by: willians nogueira
Date: November 18, 2018 10:01AM

Hi Alexander,

Thanks for helping.

I've tried everything, looked at all google information, changed my.ini parameters and got no solution at all. Very difficult to solve the problem.

I guess the problem was caused by changing "com.mysql.jdbc.Driver" (deprecated) to "com.mysql.cj.jdbc.Driver". Nothing worked anymore.

Here are the information you've requested: (all the code)

import java.sql.*;

public class Conect {

static String bd = "";

static String user = "root";

static String password = "root";

static String url = "jdbc:mysql://localhost/" + bd;

Connection conn = null;

public Conect(){

System.out.println(1);

try {

Class.forName("com.mysql.cj.jdbc.Driver");

conn=DriverManager.getConnection(url, user, password);

if(conn!=null) {

System.out.println("Conenecting database ["+conn+"] OK");

}

}catch (ClassNotFoundException e) {
System.out.println("Exception driver: "+ e.getMessage());
} catch (SQLException e) {
System.out.println("Exception connection: "+ e.getMessage());
}

}


public Connection getConnection() {
return conn;
}


public void desconectar() {

conn = null;

if(conn == null) {
System.out.println("Disconnected");

}


}

}

Options: ReplyQuote


Subject
Written By
Posted
Re: MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
November 18, 2018 10:01AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.