简体   繁体   中英

Loading class `com.mysql.jdbc.Driver'. This is deprecated

In a maven-java-sql project using hibernate, when I try to run the project this error message appears. The MySQL server is running but the the maven-java project is not able to comunicate with the MySQL server. I am using the Apache NetBeans IDE and Workbench as the server tool. Here is my persistence class

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence              http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
  <persistence-unit name="Persistence" transaction-type="RESOURCE_LOCAL">
    <!-- Persistence provider -->
    <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
    <properties>
      <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
      <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/technikon"/>
      <property name="javax.persistence.jdbc.user" value="root"/>
      <property name="javax.persistence.jdbc.password" value="root"/>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.hbm2ddl.auto" value="create"/>
    </properties>
  </persistence-unit>
</persistence>

the error message

在此处输入图像描述

The error message tells you that:

Caused by: java.sql.SQLSyntaxErrorException: Unknown database 'technikon'

So, you will need to connect to your RDBMS via Workbench (or CLI or whatever) and run

show databases;

See what databases you are finding in the list (beware db names like Technikon ) and change your settings accordingly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM