Boa Noite, baixei o MySQL 8.0 e o IDE Java na versão mais atualizada. Tentei conectar o java ao meu banco no MySQL, pórem n consigo por causa de um erro.
Segue meu script no Java.
private final String LOGIN = "root";
private final String SENHA = "Sei.la123";
private final String DATABASE = "escola";
private final String DRIVER = "com.mysql.cj.jdbc.Driver";
private final String URL = "jdbc:mysql://localhost:3306/"+DATABASE;
public PreparedStatement st = null;
public Connection con = null;
public ResultSet rs = null;
/**
*Realizes the connection to the database
* @return - true in case of success
*/
public boolean getConnection(){
try{
Class.forName(DRIVER);
System.out.println("Driver loaded successfully !!!");
con = DriverManager.getConnection(URL,LOGIN,SENHA);
System.out.println("Conectou ao banco");
return true;
}
catch(ClassNotFoundException erro){
System.out.println("Driver não encontrado");
return false;
}
catch(SQLException erro){
System.out.println(""+erro.toString());
return false;
}
}
public void close(){
try{
if(rs!=null)rs.close();
}catch(SQLException erro){}
try{
if(st!=null)st.close();
}catch(SQLException erro){}
try{
if(con!=null){
con.close();
//System.out.println("Desconectou");
}
}catch(SQLException erro){}
}
}
E este é o “erro” q aparece.
Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class is
com.mysql.cj.jdbc.Driver’. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
Falha na conexãojava.sql.SQLException: The server time zone value ‘Hora oficial do Brasil’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
Quando clico no conexão java.sql.SQLException, aparece escrito Source not found for conexãojava.sql…SQLException
Não sei mais o que fazer, testei varias “soluções” e nada funcionou.
Me ajudem, por favor.