2
I try to connect with Mysql, with the code below. I don’t use Hibernate or anything. It is just to connect to the database and run a simple SQL clause. I get the error that is below.
I see you have some questions with answers here, but I confess I don’t understand.
Error message:
java.sql.Sqlexception: The server time zone value 'Europe Standard Time Ocident' 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.
Code:
import java.sql.*;
public class ConnectMySql {
public static void main(String[] args) {
try {
// Estabelece a conexão
Connection cnx = DriverManager.getConnection("jdbc:mysql://localhost:3306/mondovino", "root", "senha");
// Cria um Statement
Statement stmt = cnx.createStatement();
// Executa a query
ResultSet rset = stmt.executeQuery("seletc * from paese");
// Navega no result set
while (rset.next()) {
System.out.println("Pais " + rset.getString("fips") + " -> " + rset.getString("nomepaese"));
}
}
catch(Exception e) {
e.printStackTrace();
}
}
}
I added this to my comic book URL and it worked: ? useSSL=false&useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
– Matheus Ferreira