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(){


try {


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) {




Options: ReplyQuote

Written By
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.