0
Connection code:
package br.bent.jdbc;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Connection;
public class Conexao {
private static Conexao conexao;
public static Conexao getInstance(){
if (conexao == null){
conexao = new Conexao();
}
return conexao;
}
public Connection getConnection() throws ClassNotFoundException,SQLException{
Class.forName("com.mysql.jdbc.Driver");
return DriverManager.getConnection("jdbc:mysql://localhost:3306/consultab","root","root");
}
public static void main(String[]args){
try{
System.out.println(getInstance().getConnection());
} catch (Exception e){
e.printStackTrace();
}
}
Resulting error:
Invalid authorization specification message from server: "Access denied for user 'nobody'@'localhost' (using password: NO)"
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2001)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1907)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:2524)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:818)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1808)
at com.mysql.jdbc.Connection.<init>(Connection.java:452)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at br.bent.jdbc.Conexao.getConnection(Conexao.java:20)
at br.bent.jdbc.Conexao.main(Conexao.java:24)
Another detail I didn’t mention is the following I’m using mysql Workbench 6.3,and the version of Connector is 5.1 This error.
Now there is another detail I am using Mysql Workbench 6.3 and the Connector is version 5.1 that error.
– Gleiston Jose de Santana