eclipse mysql database connection prompt The server time zone value 'Öйú ± ê × ¼Ê ± ¼ä' is unrecognized or represents more than one time zone. Solution

Abnormal Screenshot:

 

 

Error reason : because the installation of mysql default is the US time zone, and time zone between China and the United States where the areas where we are not the same as a result

Solution : behind the url add serverTimezone = UTC?

The revised code is :

public static void main(String[] args){
        try {
            Class.forName ( "com.mysql.cj.jdbc.Driver" );
             // database configuration information 
            String url = "jdbc:? MySQL: //127.0.0.1: 3306 UTC serverTimezone =" ;
             // account 
            String username = " root " ;
             // password 
            String password =" 123456 " ;
            Connection con=DriverManager.getConnection(url,username,Password);
            System.out.println(con);
            // close the database 
            con.close ();
        } catch (ClassNotFoundException e) {
            e.printStackTrace ();
        } catch (SQLException e) {
            e.printStackTrace ();
        }
    }

Guess you like

Origin www.cnblogs.com/puhongjun/p/12114959.html