将Hibernate与Postgres一起使用需要哪些配置设置?

时间:2012-07-25 07:54:57

标签: java hibernate postgresql

hibernate连接到postgresql的配置是什么?

代码是

import org.hibernate.cfg.Configuration;
public class StudentHibernate {
    public static void main(String[] args) {
        Configuration config = new Configuration();
        config .setProperty("hibernate.dialect","org.hibernate.dialect.PostgreSQL");
        config.setProperty("hibernate.connection.driver_class","");
    }
}

2 个答案:

答案 0 :(得分:1)

试试这个:

config .setProperty("hibernate.dialect","org.hibernate.dialect.PostgreSQLDialect");
config.setProperty("hibernate.connection.driver_class"," org.postgresql.Driver");

此致

答案 1 :(得分:0)

我通常使用这个:

hibernate.connection.username=user
hibernate.connection.password=password
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
hibernate.connection.url=url
hibernate.connection.driver_class=org.postgresql.Driver