@@ -27,8 +27,18 @@ public MySQLTimeZoneComparison(Connection connection)
27
27
28
28
public void compareTimeZone () throws SQLException
29
29
{
30
- // TODO error check.
31
- TimeZone serverTimeZone = getServerTimeZone ();
30
+ TimeZone serverTimeZone = null ;
31
+ try {
32
+ serverTimeZone = getServerTimeZone ();
33
+ } catch (SQLException ex ) {
34
+ logger .error (String .format (Locale .ENGLISH ,"SQLException raised %s" ,ex .toString ()));
35
+ }
36
+
37
+ if ( serverTimeZone == null ){
38
+ logger .warn ("Can't get server TimeZone" );
39
+ return ;
40
+ }
41
+
32
42
TimeZone clientTimeZone = TimeZone .getDefault ();
33
43
Date today = new Date ();
34
44
int clientOffset = clientTimeZone .getRawOffset ();
@@ -49,7 +59,9 @@ public void compareTimeZone() throws SQLException
49
59
"The client timezone(%s) is different from the server timezone(%s). The plugin will fetch wrong datetime values." ,
50
60
clientTimeZone .getID (),serverTimeZone .getID ()));
51
61
logger .warn (String .format (Locale .ENGLISH ,
52
- "Use `options: { useLegacyDatetimeCode: false }`" ));
62
+ "Use `You may need to set options useLegacyDatetimeCode and serverTimeZone`" ));
63
+ logger .warn (String .format (Locale .ENGLISH ,
64
+ "Ex. `options: { useLegacyDatetimeCode: false, serverTimeZone: UTC }`" ));
53
65
}
54
66
logger .warn (String .format (Locale .ENGLISH ,"The plugin will set `useLegacyDatetimeCode=false` by default in future." ));
55
67
@@ -72,7 +84,6 @@ private TimeZone getServerTimeZone() throws SQLException
72
84
return fromGMTOffsetSeconds (offsetSeconds );
73
85
}
74
86
else {
75
- // TODO Error check.
76
87
return null ;
77
88
}
78
89
0 commit comments