Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)
I am having a new Spring MVC project, and I have installed the Hibernate and the PostgreSQL drivers using Maven.

So how can I able to connect PostgreSQL with the Hibernate.

Any help here, please?

1 Answer

0 votes
by (12.7k points)

This is a hibernate.cfg.xml for PostgreSQL and this will help you with the basic hibernate configurations for PostgreSQL.

<!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>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.username">postgres</property>
        <property name="hibernate.connection.password">password</property>
        <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/hibernatedb</property>



        <property name="connection_pool_size">1</property>

        <property name="hbm2ddl.auto">create</property>

        <property name="show_sql">true</property>



       <mapping class="org.javabrains.sanjaya.dto.UserDetails"/>

    </session-factory>
</hibernate-configuration>

Are you pretty much interested to Learn SQL in detail? Join the SQL Course to gain more knowledge.

Related questions

0 votes
1 answer
0 votes
3 answers
asked Dec 4, 2020 in SQL by Appu (6.1k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...