1. 程式人生 > >jdbc驅動亂碼Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException

jdbc驅動亂碼Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException

錯誤提示:

Mon Aug 13 17:07:41 CST 2018 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.
Exception in thread "main" org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (The server time zone value '�й���׼ʱ��' 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.)
	at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
	at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
	at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
	at org.apache.commons.dbutils.AbstractQueryRunner.prepareConnection(AbstractQueryRunner.java:204)
	at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:305)
	at lsl.jdbcljc.DataSourceTest.main(DataSourceTest.java:15)
Caused by: java.sql.SQLException: The server time zone value '�й���׼ʱ��' 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.
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:69)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1606)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:633)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)
	at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
	at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
	at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
	at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
	... 5 more
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���׼ʱ��' 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.
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
	at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)
	at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)
	at com.mysql.cj.jdbc.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:118)
	at com.mysql.cj.mysqla.MysqlaSession.configureTimezone(MysqlaSession.java:293)
	at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:2399)
	at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1739)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)
	... 12 more

解決方法:

jdbc:mysql://localhost:3306/demo?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

大概原因:

 JDBC驅動程式的5.1.33版本與UTC時區配合使用,必須在連線字串中明確指定serverTimezone。



相關推薦

jdbc驅動亂碼Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException

錯誤提示:Mon Aug 13 17:07:41 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According t

com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value '?й??? mysql-installer-community-8.0.15.0

.com uid .repo als bsp word report one exception <properties> <project.build.sourceEncoding>UTF-8</project.build.source

Caused by com mysql jdbc MysqlDataTruncation Data truncati

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

MySQL異常:Caused by: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to timeout or client request

model out exec actions tracing ror pda tin dsta Caused by: com.mysql.jdbc.exceptions.MySQLTimeoutException: Statement cancelled due to ti

Oozie時出現Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure?

  不多說,直接上乾貨!   問題詳情 [[email protected] oozie-4.1.0-cdh5.5.4]$ bin/ooziedb.sh create -sqlfile oozie.sql -run DB Connection [[email&#

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 解決方案

當我將資料庫放到伺服器遠端訪問的時候出現了Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: SELECT command denied to user 'sq_shiyezhe'@'2

Eclipse+Maven+Hibernate+com.mysql.cj.jdbc.Driver 問題(無法現在驅動問題)

Eclipse+Maven+Hibernate+com.mysql.cj.jdbc.Driver  問題 問題描述: eclipse匯入maven專案之後,在我點選 Run  on  server 提示下面內容: Cannot load JDBC driver clas

java.lang.UnsupportedClassVersionError: com/mysql/cj/jdbc/Driver : Unsupported major.minor version 5

jdbc erro sql support nor jdk8 drive 新版 driver 原因: com/mysql/cj/jdbc/Driver是6.0版本的驅動,兼容JDK8環境,不兼容JDK7環境,在基於jdk7的tomcat中編譯運行會出錯,在基於jdk8的

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'.

技術 loading 使用 -c drive sql mysql- 連接 不可 在連接數據庫時,使用了最新版本的mysql-Connector,所以導致老版本的“com.mysql.jdbc.Drive”不可行,要改為“com.mysql.cj.jdbc.Driver”

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj....

今天使用 mysql-8.0.13版本資料庫連結時出現了以下問題 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The

com.mysql.cj.jdbc.Driver

# Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registere

Spring整合mybatis時,資料庫配置com.mysql.jdbc.Driver和com.mysql.cj.jdbc.Driver區別

1、#mysql-connector-java 5 用法 spring.datasource.driver-calss-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnico

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

最近在空閒時間學習的時候,往伺服器上部署專案遇到無法連線資料庫,啟動報錯的問題,最後排查下來是一個簡單的配置造成的,特此記錄。 伺服器:centos 7 mysql:5.7.23 tomcat:8.5.34 jdk:1.8.0_181 說明:由於是自己練手的專案

Java連線MySQL資料庫8.0以上版本遇到的坑(The new driver class is `com.mysql.cj.jdbc.Driver)

我遇到了java無法連線mysql資料庫8.0.1的問題。         報錯:Loading class `com.mysql.jdbc.Driver'. This is deprecated.

使用 spring boot 預設的 mysql 驅動,出現 The new driver class is `com.mysql.cj.jdb 問題

以前使用的是 5.1.31 的 mysql 驅動,後面使用 spring boot 預設的 mysql 驅動,就出現了一些異常。 異常如下(在 IDEA 上是一條紅色的英文): Loading clas

mybatis報錯com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value

專案中遇到時間存入資料庫時報錯com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Incorrect date value: 'Fri Dec 21 15:19:22 CST 2018' for column 'U

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj....

今天使用 mysql-8.0.13版本資料庫連結時出現了以下問題 Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Dr

com.mysql.jdbc.Driver 和 com.mysql.cj.jdbc.Driver的區別 serverTimezone設定 【轉】

原文轉載自https://blog.csdn.net/superdangbo/article/details/78732700 com.mysql.jdbc.Driver 是 mysql-connector-java 5中的, com.mysq

Mysql版本的相關問題:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver

1. 在使用mysql時控制檯日誌報錯如下:Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The d

java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver 找不到jar包的問題,路徑問題

驅動 -c 找到 查找 找不到 查找字符串 https 問題 not 1、參考連接:   https://blog.csdn.net/huangbiao86/article/details/6428608 折騰了一上午,找到了這錯誤的原因。哎…&helli