java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more

2018年08月15日 21:17:31 Going_cc 阅读数:34297

最近很多次遇到 The server time zone value ‘?D1ú±ê×?ê±??‘ is unrecognized or represents more than one time zone这个问题, 
报错为:

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
### The error may exist in com/wj/mapper/UserLoginMapper.xml
### The error may involve com.wj.mapper.UserLoginMapper.selectByName
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Connections could not be acquired from the underlying database!
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:982)
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
root cause

java.sql.SQLException: The server time zone value ‘?D1ú±ê×?ê±??‘ 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.
    com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:127)
    com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
    com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:87)
    com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:61)
    com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:71)
    com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
    com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:862)
    com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444)
    com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:230)
    com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:226)
    com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
    com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
    com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
    com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
    com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
    com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
    com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
    com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
    com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)

网上的说

法也很多,经过测试,有效的一个办法如下: 
 
即可解决这个错误!

java.sql.SQLException: The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents more

2018年06月02日 12:11:17 吕曌 阅读数:5037

1 报错代码:

加载类“com.mysql.jdbc.Driver”。这已被弃用。新的驱动程序类是`com.mysql.cj.jdbc.Driver‘。驾驶员通过SPI自动注册和驱动程序类的

连接数据库... 
星期六6月2日10时47分02秒CST 2018 WARN:建立无服务器的身份验证SSL连接不推荐使用。根据MySQL 5.5.45 +,5.6。 26+和5.7.6+的要求,如果未设置显式选项,则必须默认建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为‘false‘。您需要通过设置useSSL = false显式禁用SSL,或者设置useSSL = true并为服务器证书验证提供信任库。java.sql.SQLException 
:服务器时区值‘???ê×?? ?? ??” 无法识别或代表多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。在com.mysql.cj.jdbc.exceptions。 SQLError.createSQLException(SQLError.java:127)在com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)

2 错误截图

3 工具版本:

mysql - 5.7.21

JDBC驱动:MySQL的的连接器的Java的8.0.11.jar

4 错误分析:

出现这种错误一般是JDBC驱动版本的原因

5错误1:

加载类“com.mysql.jdbc.Driver” 。这已被弃用。新的驱动程序类是`com.mysql.cj.jdbc.Driver‘ 驱动程序通过SPI自动注册,通常不需要手动加载驱动程序类。

解决方法:这个问题很简单按照它的提示把代码中com.mysql.jdbc.Driver改成com.mysql.cj.jdbc.Driver就可以了

修改前代码:

 static final String JDBC_DRIVER =“com.mysql.jdbc.Driver”; 

修改后代码:

 static final String JDBC_DRIVER =“com.mysql.cj.jdbc.Driver”; 

错误2:Sat Jun 02 11:40:45 CST 2018 WARN:建议不建立服务器身份验证的SSL连接。根据MySQL 5.5.45 +,5.6.26 +和5.7.6+的要求,如果未设置显式选项,则必须默认建立SSL连接。为了符合不使用SSL的现有应用程序,verifyServerCertificate属性设置为‘false‘。您需要通过设置useSSL = false显式禁用SSL,或者设置useSSL = true并且为服务器证书验证提供信任库。

解决方法:

这是一个警告  ,即在原来的数据库名称后面添加:?useUnicode=true&characterEncoding=utf-8&useSSL=false

修改前代码:

 static final String DB_URL =“jdbc:mysql:// localhost:3306 / runoob”;

修改后代码:

  1. static final String JDBC_DRIVER =“com.mysql.cj.jdbc.Driver”;

  2.  

    static final String DB_URL =“jdbc:mysql:// localhost:3306 / runoob?useUnicode = true&characterEncoding = utf-8&useSSL = false”;

错误3:

java.sql.SQLException中:服务器时区值‘??? EE×??±??‘ 。无法识别或代表多个时区如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。

解决方法:

这是由于数据库和系统时区差异所造成的,在JDBC连接的URL后面加上serverTimezone = GMT即可解决问题,如果需要使用GMT + 8时区,需要写成GMT%2B8,否则会被解析为空。再一个解决办法就是使用低版本的MySQL jdbc驱动,

修改前代码:

  1. static final String JDBC_DRIVER =“com.mysql.cj.jdbc.Driver”;

  2.  

    static final String DB_URL =“jdbc:mysql:// localhost:3306 / runoob?useUnicode = true&characterEncoding = utf-8&useSSL = false”;

修改后代码:

  1. static final String JDBC_DRIVER =“com.mysql.cj.jdbc.Driver”;

  2.  

    静态最后弦乐DB_URL =“?JDBC:MySQL的://本地主机:3306 / runoob了useUnicode =真的characterEncoding = UTF-8&useSSL =假serverTimezone = GMT“;

最后问题解决:

java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more

原文地址:https://www.cnblogs.com/sundaysjava/p/10325288.html

时间: 2024-09-28 16:15:42

java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more的相关文章

MySql数据库时区异常,java.sql.SQLException: The server time zone value &#39;?&#208;&#185;???&#215;&#188;&#202;&#177;?&#39; is unrecognized or represents more than one time zone.

JDBC访问MySql异常 Exception in thread "main" org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause: java.sql.SQLException: The server time zone value '?D1???×?ê±?' is unrecognized or represents more than one time zon

java.sql.SQLException: The server time zone value &#39;&#214;&#208;&#185;&#250;&#177;&#234;&#215;&#188;&#202;&#177;&#188;&#228;&#39; is unrecognized

Exception in thread "main" java.sql.SQLException: The server time zone value '?D1ú±ê×?ê±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property

nested exception is java.sql.SQLException: The server time zone value &#39;&#214;&#208;&#185;&#250;&#177;&#234;&#215;&#188;&#202;&#177;&#188;&#228;&#39; is unrecognized异常

在连接数据库时出现以下异常 : nested exception is java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized 出现原因 : 数据库时区问题 解决办法 : 1. 在终端开启mysql, 输入以下命令 : show variables like '%time_zone%'; 2. 继续输入以下命令 : set global time_zone='+8:00'; nested e

Exception in thread “main” java.sql.SQLException: The server time zone value ‘?й???????’ is unrecognized or represents more than one time zone.

Exception in thread "main" 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) t

java.sql.SQLException: The server time zone value &#39;?й???????&#39; is unrecognized or represents more than one time zone.

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 v

连接mysql报错java.sql.SQLException: The server time zone value &#39;?й???????&#39; is unrecognized...解决方法

报错内容: 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

java.sql.SQLException: The server time zone value &#39;?й???????&#39; is unrecognized or represents more tha

Caused by: com.mysql.cj.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 configur

java.sql.SQLException: The server time zone value ‘?й???????’ is unrecognized or represents more than one time zone.

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 v

java.sql.SQLException: The server time zone value 。。。的解决办法

由错误信息可知:The server time zone value ,关于这个版本,在Mysql服务的新版中种最为常见,因为我导入的包版本为mysq-connector-java-8.0.15.jar,在新版的数据库使用的时区与本地时区有区别,标准时区使用的是Unix元年的时间为起始点到当前时间中间所做的动作.国际标准失去与本地相差 8 个小时. 解决方法1: 因为我们在UTC+8 解决方法2: 在连接MySQL服务时,直接指定时区为UTC 即:jdbc:mysql://127.0.0.1:3