Mysql database version 5.6, jdbc driver package mysql-connector-java-5.1.49-bin version, start tomcat, and an error is reported when connecting to the database. Details:
java.lang.NullPointerException java.util.Properties$LineReader.readLine(Properties.java:434) java.util.Properties.load0(Properties.java:353) java.util.Properties.load(Properties.java:341) com.mysql.cj.jdbc.util.TimeUtil.loadTimeZoneMappings(TimeUtil.java:163) com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:109) com.mysql.cj.mysqla.MysqlaSession.configureTimezone(MysqlaSession.java:308) com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2474) com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1817) com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1673) com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:656) com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:349) com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:221)
After query, it is said that the exception is thrown because the format of the MySQL server time zone (inherited from the system time zone) is different from that expected by the MySQL connector.
Add the JDBC URL to the servertimezone, for example:
servertimezone = UTC , where UTC is the unified standard world time; China is in the East eighth district. If you need to specify the time zone as China, you can modify the configuration to
servertimezone = GMT% 2B8 .
About time zone:
UTC, coordinated universal time. UTC is a time measurement system based on atomic time and second length, which is as close as possible to GMT in time. To ensure that UTC does not differ from GMT by more than 0.9 seconds, positive or negative leap seconds will be added to UTC if necessary. UTC is now used as world standard time
GMT: Greenwich mean time, that is, universal time. Noon in GMT refers to the time when the sun crosses the Greenwich meridian (primary meridian). However, due to the uneven and irregular rotation of the earth, GMT is not accurate, and it is no longer used as the world standard time
UTC is basically the same as GMT, with an error of no more than 0.9 seconds
- Overview of several common time of CET, UTC, GMT and CST
- Failed to obtain JDBC Connection
- [Solved] Ambari Start Error: The server time zone value ‘EDT’ is unrecognized or represents more than one time zone
- mysql connection reports java.math.BigInteger cannot be cast to java.lang.Long exception
- Error occurred when Android connected to cloud MySQL: java.lang.NoClassDefFoundError : Failed resolution of: Ljava/sql/SQLType
- Java.math.BigInteger cannot be cast to java.lang.Long [How to Solve]
- What are GMT, UTC and PDT? How to adjust time zone under Linux
- Project startup error: communications link failure
- SSM Project Error: java.sql.SQLException: Access denied for user ‘????…§’@’localhost’ (…
- [Solved] Error: The server time zone value ‘???ú±ê×??±??’ is unrecognized or represents more than one time zone.