Scala 连接mysql 时出现的BUG

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.

"C:\Program Files\Java\jdk1.8.0_151\bin\java" "-javaagent:D:\软件\IntelliJ IDEA 2017.2.5\lib\idea_rt.jar=53642:D:\软件\IntelliJ IDEA 2017.2.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_151\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_151\jre\lib\rt.jar;E:\IDEA_PROJECT\Test\target\classes;E:\新建文件夹\marvenjar\org\scala-lang\scala-library\2.11.11\scala-library-2.11.11.jar;E:\新建文件夹\marvenjar\mysql\mysql-connector-java\6.0.6\mysql-connector-java-6.0.6.jar" com.zhiyou.UtilPackage.SqlTest
Thu Nov 16 22:01:40 GMT+08:00 2017 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: 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 java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at com.zhiyou.UtilPackage.SqlTest$.main(SqlTest.scala:18)
    at com.zhiyou.UtilPackage.SqlTest.main(SqlTest.scala)
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 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    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)
    ... 7 more
Exception in thread "main" java.lang.NullPointerException
    at com.zhiyou.UtilPackage.SqlTest$.main(SqlTest.scala:35)
    at com.zhiyou.UtilPackage.SqlTest.main(SqlTest.scala)

Process finished with exit code 1

解决方法

 val url ="jdbc:mysql://localhost/fiftyquestion?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
时间: 2024-11-03 20:56:48

Scala 连接mysql 时出现的BUG的相关文章

使用工具连接mysql时的错误提示

今天,同事在使用工具连接mysql时,发现了一个错误提示,如下 有问题,就看错误日志,同样发现了一条错误信息,如下 [ERROR] Incorrect definition of table mysql.proc: expected column 'comment'at position 15to have type text, found type char(64). 说是mysql.proc这个表的comment字段类型应该为text,但是却是char(64). 按照错误信息的提示,只要将c

mysql-在Windows32进行自定义环境搭建测试PHP连接MySQL时总是提示Fatal error: Call to undefined function

问题描述 在Windows32进行自定义环境搭建测试PHP连接MySQL时总是提示Fatal error: Call to undefined function 已经打开extension=PHP_mysql和extension=PHP_mysqli用phpmyadmin测试显示PHP配置错误 可是找不到错误 解决方案 PHP连接Mysql数据库报错:Fatal error: Call to undefined function mysql_connect()Fatal error: Call

jdbc-安卓新手用JDBC连接mysql时一直报错

问题描述 安卓新手用JDBC连接mysql时一直报错 抛出异常在logcat提示:驱动连接成功,数据库连接失败Could not find class 'javax.naming.StringRefAddr', referenced from method com.mysql.jdbc.ConnectionPropertiesImpl$ConnectionProperty.storeTo.求大神帮忙,错误围绕好长时间了 连接代码 //连接数据库 public static Connection

mysql jsp-jsp连接mysql时运行sql语句失败

问题描述 jsp连接mysql时运行sql语句失败 四月 01, 2016 12:51:30 下午 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet [jsp] in context with path [/Test] threw exception [An exception occurred processing JSP page /register.jsp at li

用VS2012连接MySQL时,选择数据源却没有MySQL database该选项,只有SQL Server相关的,是怎么回事啊?

问题描述 我用VS2012建立了一个Asp.NET网站项目,可是当我与MySQL数据库连接时却没有MySQLDataBase这一个数据源选项: 解决方案 解决方案二:有了啊,你没看到吗?解决方案三:MySql.Data.dll解决方案四: 解决方案五:sqlserver有没有安装数据库实例?解决方案六:引用2楼wangdoublejia的回复: MySql.Data.dll +1楼主,你要在项目的库中添加下,连接MySql的动态链接库.名称是MySql.Data(要从网上下载),添加到项目中的引

急!!!为什么我vs2010连接mysql时找不到mysql数据源??

问题描述 vs2010连接mysql,我打开mysql服务,但是在服务器资源管理器中添加新的数据源,里面没有mysql选项,这是什么原因??? 解决方案 解决方案二:各位大神帮帮忙~~!!!解决方案三:本帖最后由 net_lover 于 2012-05-04 21:11:27 编辑解决方案四:不必用服务器资源管理器,自己在配置文件中写连接字符串,例:<connectionStrings><addname="MySqlConnectionString"connectio

JSP连接MySQL时老是遇到驱动错误怎么办?

在使用JSP进行web开发的时候总是会不可避免的遇到各种各样的问题.今天我也来讲一讲我遇到的一些奇葩的问题. 驱动出错 一开始我总是以为是我导入到工程的里的jar包的问题,于是我就试验了好几个连接MySQL的时候用得到的jdbc的jar包. 事实上我使用的jar包JSE的时候是经得起实践检验的,但不知怎么的在JEE的开发过程中就是不行. 还是会报出com.mysql.jdbc.Driver Can not Found! 的异常,这让我很是苦恼,最后发现如果在Tomcat的lib目录下将使用到的j

navicat连接mysql时出现1045错误的解决方法

navicat for MySQL 连接本地数据库出现1045错误 如下图: 查了很多资料,意思是说mysql没有授权远程连接,也就是权限不够: 解决方法: 1.首先打开命令行:开始->运行->cmd. 2.先进入电脑安装的mysql的bin目录下,因为我用的是phpstudy,mysql安装在D盘,如果你的是C盘 就不用执行第一个命令 D: cd D:\phpStudy\MySQL\bin mysql -u root mysql mysql> UPDATE user SET Passw

请教rails连接mysql时没有设置encoding:utf8后保存的中文乱码如何转为正常

问题描述 在database.yml中没有设置encoding:utf8,使用时界面上都正常,但是保存到mysql数据库中的中文都是乱码.现在在database.yml中加上了encoding:utf8,结果以前保存的中文数据在界面上都变成乱码了..,但是新添加的数据都没问题,数据库和界面上都正常请问是否有办法把数据库中以前保存的乱码都转换成正常的数据?问题补充:ek2兄:我以前保存成乱码的数据还有用处,希望能恢复. 解决方案 把乱码的数据全部dump出来保存为SQL文件.然后用UltraEdi