How to adjust the Mysql Time Zone?

Asked

Viewed 13,010 times

4

I took an old project from github, and the project was a JSF application that was using the old mysql artifact as you can see below;

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.25</version>
            <scope>compile</scope>
        </dependency>

and was generating errors, and so I understood should switch to the version compatible with the version I was using in my database, so I went to check the version of my command with the command;

inserir a descrição da imagem aqui

So I traded it for this artifact;

<dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.11</version>
        </dependency>

When I submitted my form I came across an error 500 on the browser screen, and when I went to check the error log in my eclipse find briefly this error;

Caused by: com.mysql.Cj.exceptions.Invalidconnectionattributeexception: The server time zone value 'Official Time in Brazil' 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.

So it was about adjusting the mysql time zone, but how to do it? I made my attempts and could not, that’s why I’m asking for help!

I’ve made these attempts

How to adjust the time zone or Timezone in Mysql

How to set Mysql time zone by names.

With the command SELECT @@time_zone; gave this result below;

inserir a descrição da imagem aqui

So I changed running this command;

SET @@global.time_zone = '+3:00';
QUIT

inserir a descrição da imagem aqui

I tried to execute the command SET time_zone='America/Sao_Paulo'; but gave incorrect command.

After that I ran the application again and it worked normally, but when restarting the computer and trying everything again got the problem again.

Please, I would like someone to explain to me how to properly adjust the time zone so I have no problems running my applications.

1 answer

4

I just solved.

In the file persistece.xml was like this

<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/boleto"/> 

But now it’s like this;

<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/boleto?serverTimezone=UTC"/> 

After the amendment worked perfectly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.