'hibernate.dialect' must be set when no Co

2020-07-03 06:51发布

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.

9条回答
欢心
2楼-- · 2020-07-03 07:39

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.

查看更多
祖国的老花朵
3楼-- · 2020-07-03 07:42

I had the same errors. My problem was that I put the hibernate.properties under one package instead of the src. So my solution to my problem was moving hibernate.properties from package to src.

查看更多
叛逆
4楼-- · 2020-07-03 07:44

Just encountered this issue. In my case it was the hibernate.dialect configuration.I added the following to SessionFatcory config in spring context file:

<bean id="mySessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="annotatedClasses">
        <list>
            <value>com.testapp.service.geolocation.LocationData</value>
            <value>com.testapp.service.profiles.Profile</value>
        </list>
    </property>    
     <property name="hibernateProperties">
        <value>hibernate.dialect=org.hibernate.dialect.HSQLDialect</value>
    </property>
 </bean>
查看更多
登录 后发表回答