Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'hibernate.dialect' must be set when no Connection available error

Tags:

java

hibernate

I am getting the following error when using Hibernate:

'hibernate.dialect' must be set when no Connection available

And I am using a datasource for database connection.

like image 321
star Avatar asked Sep 10 '13 11:09

star


2 Answers

You will get this issue even if you have your configuration files having proper value but you don't configure it in the code.

I was explaining hibernate, I forgot to use configure() before buildSessionFactory() so I was getting the error.

You might want to recheck it.

Previous code which was giving me error

SessionFactory factory = new Configuration().buildSessionFactory();

Changed code No Error

SessionFactory factory = new Configuration().configure().buildSessionFactory();
like image 95
NewUser Avatar answered Oct 04 '22 01:10

NewUser


The issue could be that you haven't installed the client library for the database you are trying to connect to.

I have a Spring application that does not have a persistence.xml file and therefore no hibernate.dialect declaration.

Once I installed the MySQL Connector/J client library the error went away.

EDIT: I've also gotten this error when the database server wasn't running. Something that often happens now that I run my MySQL server through MAMP.

like image 30
emurano Avatar answered Oct 04 '22 00:10

emurano