Java 无法使用Hibernate(Eclipse)连接到postgreSQL

Java 无法使用Hibernate(Eclipse)连接到postgreSQL,java,eclipse,postgresql,hibernate,Java,Eclipse,Postgresql,Hibernate,我做错了什么?运行main类后,我在控制台中看到了下面的当前屏幕截图,控制台继续工作,什么也没发生 hibernate.cfg.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-c

我做错了什么?运行main类后,我在控制台中看到了下面的当前屏幕截图,控制台继续工作,什么也没发生

hibernate.cfg.xml:

<?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>
    <property name="connection.driver_class">org.postgresql.Driver</property>
    <property name="connection.url">jdbc:postgresql://localhost:5432/Gillie_PL</property>
    <property name="connection.username">postgres</property>
    <property name="connection.password">postgres</property>
    <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="show_sql">true</property>
    <property name="hbm2ddl.auto">update</property>
   </session-factory>
</hibernate-configuration>
}

主要类别:

package hibernateConn;
import org.hibernate.SessionFactory;
public class Main {
  public static void main(String[] args) {
    SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
   }
}
在控制台中运行Main.class之后:

就这些。没什么了,程序继续工作,什么也没发生,就像发生了递归一样。。。可能我没有正确指定xml中的设置?


我重写了HibernateUtil.class:

static {
    try{
        sessionFactory = new Configuration().configure("/hibernateConn/hibernate.cfg.xml").buildSessionFactory();
    }catch(Throwable ex){
        System.err.println("++++Initial SessionFactory creation failed.++++: " + ex);
        ex.printStackTrace();
    }
}

public static SessionFactory getSessionFactory(){
    return sessionFactory;
}

这一切都奏效了。这个问题可以结束。

我重写了HibernateUtil.class,一切都成功了。这个问题可以结束了
static {
    try{
        sessionFactory = new Configuration().configure("/hibernateConn/hibernate.cfg.xml").buildSessionFactory();
    }catch(Throwable ex){
        System.err.println("++++Initial SessionFactory creation failed.++++: " + ex);
        ex.printStackTrace();
    }
}

public static SessionFactory getSessionFactory(){
    return sessionFactory;
}