2

I keep getting the same error in my console about timezones, but I never attempt to set the timezone in my code.

public class DriverManagerTester
{

  public static void main(String[] argv) {

    Connection connection = null;

    try {

        connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/data","root", "Iamtyler8");

    } catch (SQLException e) {
        System.out.println("Connection Failed! Check output console");
        e.printStackTrace();
        return;
    }

    if (connection != null) {
        System.out.println("You made it, take control your database now!");
    } else {
        System.out.println("Failed to make connection!");
    }
  }
}

Error message in console:

Connection Failed! Check output consolejava.sql.SQLException: The server time zone value 'PDT' 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.

Don Cruickshank
  • 5,641
  • 6
  • 48
  • 48
  • 1
    *I never attempt to set the timezone in my code.* And that's precisely the problem. The error message tells you that you need to fix the MySQL server configuration, or to configure the JDBC driver (via the serverTimezone configuration property). Read the error message, carefully. – JB Nizet Jul 19 '19 at 22:11
  • How do you do that? I have been searching online for the solution to this, but I have found nothing so far. – tylerlorenzi Jul 19 '19 at 22:13
  • take a look over this post, there are some good solutions https://stackoverflow.com/questions/26515700/mysql-jdbc-driver-5-1-33-time-zone-issue – Alex Abramov Jul 19 '19 at 22:15
  • I got it now. Issue resolved – tylerlorenzi Jul 19 '19 at 22:15
  • 1
    When I google for "MySQL documentation JDBC serverTimezone", the first link points to the documentation explaining how to set the server timezone (first solution, to refer), and the second link points to the page explaining how to pass properties, including serverTiezone (second solution). – JB Nizet Jul 19 '19 at 22:17

1 Answers1

0

You can simply run this :

SET GLOBAL time_zone = '-7:00';

Use your preferred timezone

Avinash Gupta
  • 208
  • 5
  • 18