Daniil Baev
Daniil Baev

Reputation: 131

Unable to create requested service (Hibernate + JPA)

I am trying to set connection to my postgresql database for create a SessionFactoty. But, when i trying to start my application i always got errors about "Unable to create requested service"
Password, name and url are correct.

<?xml version='1.0' encoding='utf-8'?> 
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>

    <!-- Database connection settings -->
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="connection.url">jdbc:postgresql://127.0.0.1:5432/Hibernate</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">vfrae0v5</property>

    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.PostgreSQL10Dialect</property>

    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>

</session-factory>

Got this error:

Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at util.HibernateUtil.buildSessionFactory
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

Upvotes: 0

Views: 3734

Answers (2)

JLazar0
JLazar0

Reputation: 1292

Change your property to:

<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQL10Dialect" />

The error is pretty clear, you didn't specify the hibernate.dialect property

Upvotes: 1

Christian Beikov
Christian Beikov

Reputation: 16400

You don't need to set the dialect if the connection to the database is possible, but in your case it looks like you don't have a database listening on 127.0.0.1:5432

Upvotes: 0

Related Questions