• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

org.hibernate. HibernateException: database product name cannot be null

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, im getting this error in my code:
Initial Session Factory creation failed org.hibernate.HibernateException: database product name cannot be null
org. hibernate.HibernateException: database product name cannot be null
at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)

an so fourth...

The line which produces that exception is here:

Configuration forAlias = configurationForAlias(); //works fine
Session session = forAlias.buildSessionFactory().openSession();//throws exception
I've tried the following but they do not help:
Session session = forAlias.configure().buildSessionFactory() .openSession();
Session sessionFactory = new Configuration().configure().buildSessionFactory().openSession();

Does anyone have an idea WHAT the problem is...not necessarily how to fix it but exactly why does it say "database product cannot be null"??
(properties,configuration files are correct and spit out correct results);
Thanks,
Alex
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the dialect setting in your hibernate.cfg.xml?

Mark
 
Alex Shpiller
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK that is the correct dialect, there might be some other problem above it in your XML, like a missed closed tag or something like that.

But, also I noticed that you are trying to create a Session at the same time as creating a SessionFactory, these two things should be done seperately, as creating a SessionFactory is heavy-weight. So using a Singleton SessionFactory is the way to go, then just get that singleton and open Sessions from there. Opening sessions are lightweight. And it is ok if you do that often, rather than always creating new SessionFactories.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex, please post your hibernate.xml.cfg. There is a CODE button below the Add Reply button, make sure you put your xml within CODE tags so that your indentation will remain in your post, and make it easier for us to read.

I want to see if we can spot the problem. I have some guesses. 1) the version of Hibernate you are using versus the package of the Dialect classes. 2) Some single character error somewhere in your HTML.

Basically the code in Hibernate that has the error was first getting a String value from a Properties object passed to the method. These are Properties that are set in the hibernate.xml.cfg



So if that is null, then it tries to find the Dialect another way which is also failing, but I don't think that the dialectName var should be null.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic