使用驅(qū)動(dòng):
mysql-connector-java-8.0.13
https://dev.mysql.com/downloads/connector/j/
開發(fā)配置配置:
驅(qū)動(dòng)配置:com.mysql.cj.jdbc.Driver
鏈接url配置:jdbc:mysql://localhost:3306/database?useSSL=false&serverTimezone=UTC
hibernate中配置如下:
<property name="hibernate.connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://127.0.0.1:3306/hb?serverTimezone=UTC</property>
注意:
在hibernate配置時(shí)若果報(bào)錯(cuò):javax.xml.bind.JAXBException听想,需要引入以下jar:
javax.activation-1.2.0.jar
http://search.maven.org/remotecontent?filepath=com/sun/activation/javax.activation/1.2.0/javax.activation-1.2.0.jar
jaxb-api-2.3.0.jar
http://search.maven.org/remotecontent?filepath=javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar
jaxb-core-2.3.0.jar
http://search.maven.org/remotecontent?filepath=com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar
jaxb-impl-2.3.0.jar
http://search.maven.org/remotecontent?filepath=com/sun/xml/bind/jaxb-impl/2.3.0/jaxb-impl-2.3.0.jar
報(bào)錯(cuò)原因:
JAXB API是java EE 的API腥刹,因此在java SE 9.0 中不再包含這個(gè) Jar 包。
java 9 中引入了模塊的概念汉买,默認(rèn)情況下衔峰,Java SE中將不再包含java EE 的Jar包
而在 java 6/7 / 8 時(shí)關(guān)于這個(gè)API 都是捆綁在一起的。