This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes org.hibernate. HibernateException: database product name cannot be null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "org.hibernate. HibernateException: database product name cannot be null" Watch "org.hibernate. HibernateException: database product name cannot be null" New topic
Author

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

Alex Shpiller
Greenhorn

Joined: Jan 29, 2007
Posts: 2
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
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

What is the dialect setting in your hibernate.cfg.xml?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Alex Shpiller
Greenhorn

Joined: Jan 29, 2007
Posts: 2
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: org.hibernate. HibernateException: database product name cannot be null
 
Similar Threads
Problem with Hibernate Cache
Persistence: Calling Stored Procedures from Hibernate
one to one mapping problem
hibernate session: to close or not to close
SessionFactory and database product name Error