-1

Here is a part of my code. I need to build a connection to mysql data base that contains user names and passwords but all i get is a timezone error"java.sql.SQLException: The server time zone value 'Mitteleuropäische Sommerzeit' is unrecognized or represents more than one time zone." and i dont know what to do next. im using a 8.01 connector. Any help is most welcome :)

    public static Connection getCon(){
    Connection con=null;
    try{
        Class.forName("com.mysql.cj.jdbc.Driver");  
        con=DriverManager.getConnection(  
        "jdbc:mysql://localhost:3305/world","test","l1feisjapan");
    }catch(Exception e){System.out.println(e);}
    return con;
}
public static boolean validate(String name,String password){
    boolean status=false;
    try{
        Connection con=getCon();
        PreparedStatement ps=con.prepareStatement("select * from User_accountant where name=? and password=?");
        ps.setString(1,name);
        ps.setString(2,password);
        ResultSet rs=ps.executeQuery();
        status=rs.next();
        con.close();
    }catch(Exception e){System.out.println(e);}


    return status;
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

1 Answers1

0

Solution 1 :

Try setting the timezone

jdbc:mysql://localhost:3305/world?useLegacyDatetimeCode=false&serverTimezone=UTC

Solution 2 :

Look for MySQL configuration file my.ini or my.cnf file set/add below entry

# Set default time zone
default-time-zone = '+08:00'
QuickSilver
  • 3,915
  • 2
  • 13
  • 29
  • hmm got a new error :Wed Jun 03 21:48:47 CEST 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification. java.sql.SQLException: No timezone mapping entry for 'MEZ' – cray dsher Jun 03 '20 at 19:50