configure timezone JDBC driver java

Question:

I present an error when executing my code from the persistence which is the following

Exception in thread "AWT-EventQueue-0" javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: The server time zone value 'Hora est. Pac?fico, Sudam?ric' 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.

Where is the time zone configured to solve that problem?

I use the following mysql driver

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

Answer:

You can set it in the URL of the connection:

jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Here the answer in English.

Also I think, as it shows the SQL error with ? , that you should configure MySQL with ISO-8859-1 encoding so that it allows characters like ñ when trying to insert VARCHARS and your data is not corrupted.

Scroll to Top