NetBeans 7.1 Hibernate Reverse Engineering Wizard Does Not Find Database Driver

I am currently trying to go through this tutorial netbeans + hibernate + JavaSE ( http://netbeans.org/kb/docs/java/hibernate-java-se.html ). Everything is pretty good, but after creating hibernate.cfg.xml, when it comes to the part where reverse engineering is required, it comes to some strange message that the reverse engineering wizard tells me:

"The database drivers are not added to the project classpath." "Go to project properties to add database library.". 

Well, this is strange because hibernate.cfg.xml was created by netbeans. I checked the database connection with the connection data from the hibernate.cfg.xml file and everything seems to be in order, so the manual connection works very well. Does anyone know what is going on here? Am I doing something wrong?

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/sakila</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password">apassword</property> <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property> </session-factory> </hibernate-configuration> 
+4
source share
7 answers

Add this line of code to the hibernate.cfg.xml file

 <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost/DATABASE_NAME</property> <property name="hibernate.connection.username">root</property> <property name="hibernate.connection.password"/> </session-factory> 
+2
source

Besides missing jar files, here is another possible way that this netbeans error can cause this: an invalid configuration file.

So, make sure you have the correct configuration file (.cfg.xml file) to build .reveng

+1
source

Attached example configuration:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.password">1234</property> <property name="hibernate.connection.url">jdbc:mysql://161.58.103.144:3306/exampleDatabase?zeroDateTimeBehavior=convertToNull</property> <property name="hibernate.connection.username">JasonGlez</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> </session-factory> </hibernate-configuration> 

Just change ip, database name, your username and password

+1
source

You are missing a JDBC driver. In Project View, right-click on the Libraries node in your project and select Add Library... -> MySQL JDBC Driver .

0
source

As mentioned by hello, make sure hibernate.cfg.xml is good. Try to restore it, although from the NetBeans Hibernate configuration wizard, and not to create it yourself. Also, try to recreate the project and make sure that the new project wizard fills hibernate.cfg.xml with database connection parameters. This was the first time for me for the first time; I do not know why. Before it started working, I also restarted Netbeans and the computer to boot, which may not hinder a try. (The pun is not intended.)

0
source

This requires a MySQL driver, add my SQL driver to the library.

0
source

Did you find a solution? I was stuck in the same situation, it happened strange that when I tried to do it in another project, it worked, but now I get the same error as yours, my cfg file is correct and all details are also correct .. please help

0
source

Source: https://habr.com/ru/post/1394285/


All Articles