将PostgreSQL 9.2.1与Hibernate连接起来 [英] Connecting PostgreSQL 9.2.1 with Hibernate

查看:96
本文介绍了将PostgreSQL 9.2.1与Hibernate连接起来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个空白的Spring MVC项目,并且我使用Maven安装了Hibernate和PostgreSQL驱动程序。

I have a blank Spring MVC project, and I've installed Hibernate and the PostgreSQL drivers using Maven.

我在完整的教程中简要介绍了如何将PostgreSQL与Hibernate连接。

I'm running short on complete tutorials that show how to connect PostgreSQL with Hibernate.

这里有任何帮助吗?

Any help here?

推荐答案

这是一个用于posgresql的hibernate.cfg.xml,它将帮助您为posgresql提供基本的hibernate配置。

This is a hibernate.cfg.xml for posgresql and it will help you with basic hibernate configurations for posgresql.

<!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>

这篇关于将PostgreSQL 9.2.1与Hibernate连接起来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆