How to fix error with MySQL because of timezone change?

Alvaro Vila Legua

Currently in Europe the timezone was changed and now its one hour more. For some reason this broke my script, and I cant connect to my mysql database.

I tried restarting, stopping and starting mysql server, even restarting eclipse. None of this works.

    public static Connection getConnection() throws Exception{
        try {
            String driver = "com.mysql.cj.jdbc.Driver";
            String url = "jdbc:mysql://localhost:3306/db";
            String username = "root";
            String password = "***";
            Class.forName(driver);

            Connection DB = DriverManager.getConnection(url, username, password);
            System.out.println("Connected to Database");        
            return DB;
        } catch(Exception e) {System.out.println(e);        
        }

        return null;
    }

This worked before the time change, now I get this error

java.sql.SQLException: The server time zone value 'CEST' 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.

Ari

This can be fixed on the server-side with an explicit timezone setting in my.cnf. If your timezone is for instance, Europe/Berlin:

[mysqld]
default-time-zone = Europe/Berlin

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Change MySQL Timezone Windows

MYSQL error 1064 ,how to fix it?

How to fix CloudRun error 'The request was aborted because there was no available instance'

How to fix the 'cannot change constant' error

How to change mysql timezone running on inuxmint in virtual box?

How to change MySQL timezone in a database connection using Java?

How can i change timezone in the Managed MYSQL Database in DigitalOcean?

How to change the timezone?

How to change the user timezone?

Change mysql timezone from phpMyAdmin

php - mysql - change timezone not working

How can I fix MySQL error #1064?

How to fix this MySql syntax error in PHP?

How to fix join error in mysql update query

how to fix "MySQL 1064 error Syntax Workbench"

How to fix mysql query syntax error

how can fix error 1064 mysql

How to fix this mysql create table syntax error

How do I fix this MYSQL//Phpmyadmin error?

How can I fix the error: "error CS1656: Cannot assign to 'InvokeRepeating' because it is a 'method group'"?

"Job for httpd.service failed because the control process exited with error code." How do I fix this?

How to fix "Error: Can't join on '.rows' x '.rows' because of incompatible types (list / list)" using censReg

how to fix Error: Hydration failed because the initial UI does not match what was rendered on the server in my code like this

How to definitely fix this error: .NET Framework execution was aborted by escalation policy because of out of memory?

Docker: How to fix "Job for docker.service failed because the control process exited with error code"

How do I fix "file can't be opened because it is from an unidentified developer" error?

How to fix unability to save ".eps" file to marklogic database because XDMP-JSONDOC error is thrown?

How to change lightsails database timezone

How to change Hive Server Timezone