一些背景:
我在Tomcat 7上运行了一个Java 1.6 webapp.数据库是MySQL 5.5.以前,我使用Mysql JDBC驱动程序5.1.23连接到数据库.一切正常.我最近升级到Mysql JDBC驱动程序5.1.33.升级后,Tomcat会在启动应用程序时抛出此错误.
WARNING: Unexpected exception resolving reference
java.sql.SQLException: The server timezone value 'UTC' is unrecognized or represents more than one timezone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc timezone value if you want to utilize timezone support.
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
我正在尝试设置一个简单的hibernate应用程序,当我运行它时,我得到一个充满错误的堆栈跟踪.
我的文件中有以下maven依赖项pom.xml:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.0.Final</version>
</dependency>
<!-- http://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我在本地运行的mysql版本是:
5.7.9, for osx10.11 (x86_64)
Run Code Online (Sandbox Code Playgroud)
我正在运行,似乎是一种非常简单的方法,但仍然会出现错误:
// create session factory
SessionFactory factory = new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Model.class)
.buildSessionFactory();
// create session
Session session = factory.getCurrentSession();
Model newModel = new Model("....", "...", "...");
// start a transaction
session.beginTransaction();
// save the student object
System.out.println("Saving the model...");
session.save(newModel);
Run Code Online (Sandbox Code Playgroud)
执行上面的操作后,我得到一个很长的堆栈跟踪...... System.out.println也没有打印...所以连接似乎没有连接.
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Thu Jun 09 17:36:28 EST 2016 WARN: …Run Code Online (Sandbox Code Playgroud) 我在本地系统窗口中使用springboot,maven,连接器:mysql-connector-java-8.0.11。我有这个错误,
java.sql.SQLException:服务器时区值'Hora de verano GMT'无法识别或代表多个时区。如果要利用时区支持,必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更特定的时区值。
我已经在mysql文件my.ini中进行了修改,我输入了:timezone ='UTC'。我已经更改为mysql-connector-java-8.0.12,同样的错误。我已经尝试了5.1.46,但我还是遇到其他错误。
谢谢