0

I am newbie to h2 database.I have created some tables in h2 using browser console. when i try to create the hibernate.cfg file it creates like below.

<?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">org.h2.Driver</property>
    <property name="hibernate.connection.url">jdbc:h2:~/selva</property>

  </session-factory>
</hibernate-configuration>

But when i try to create a reverse engineering i got the below error.

why it happens?.Netbeans create reverse enginnering file for mysql and mssql databse.But why not create the h2?

Cannot establish database connection with selected Hibernate Configuration file. Please verify the database connection details in hibernate.cfg.xml.

1.How to solve the above issue?
2.Is Querying  inmemory database in hibernate is different from the persistent database?
2.Is Configuring inmemory database in hibernate  is different from the persistent database?

Any help will be greatly appreciated!!!

Selva
  • 1,620
  • 3
  • 33
  • 63
  • Aren't you missing (at least) a username for your connection? – Joachim Rohde Jan 20 '15 at 10:03
  • @Joachim,I execute the queries without using hibernate that works for me.but i cannot able to perform that in hibernate – Selva Jan 20 '15 at 10:08
  • Having a quick glance at the official site (http://www.h2database.com/html/cheatSheet.html): does it work if you specify the dialect: org.hibernate.dialect.H2Dialect ? – Joachim Rohde Jan 20 '15 at 10:16

2 Answers2

0

hey i was having the same issue, so i just right clicked the default package under the source package of the particular project in netbeans and then made the reverse engineering file...netbeans is then successfully creating the hibernate.reveng.xml file

-2

You must start MySQL service and then connect to MySQL. Then go to services tab in Netbeans. Then stop Java db. Delete any Java db connection. Then go to MySQL Server Properties. Select basic properties and enter them. Then select

Admin Properties
  • Path/Url to admin tool: c:\program files(x86)\mysql\mysql workbench 6.3 cE\MySQLWorkbench.exe

Admin tool you can use phpmyadmin, dbeaver, dbforgestudio, sql yog or any other thing.

  • Path to stop command:
  • Arguments: -uroot -proot shutdown

if root is your username and password. First never store your libraries in a dedicated folder

  • Click File > New Project
  • Select Java Web Application
  • Select project name, uncheck use dedicated folder for storing libraries
  • Select Apache Tomcat then under frameworks select Hibernate 4.3.1
  • Select New Database Connection
  • Select driver Mysql(connector/J driver) then test connection if okay click Finish

Then you must be able to do database operations from Netbeans.

  • Click the project select New > Other > Hibernate > Hibernate Reverse Engineering Wizard > then name > then hibernate.cfg.xml > finish
  • Then you must see hibernate connection properties in the cdg file.

When Netbeans makes connection to db it will takes some time or some blinking, then you are making the correct move.

enter image description here

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Noby Nirmal
  • 353
  • 2
  • 5