Java org.postgresql.util.PSQLException:错误:关系;雇员1“;不存在

Java org.postgresql.util.PSQLException:错误:关系;雇员1“;不存在,java,postgresql,Java,Postgresql,我是postgresql和hybernate的新手,在我的第一个程序中遇到了一个问题,请您帮助我,并提前表示感谢 它打印评论 Hibernate: /* insert testhybernate1.Employee */ insert into employee1 (ename, mobile, email, id) values (?, ?, ?, ?) 并给出了错误:- org.postgresql.util.PSQ

我是postgresql和hybernate的新手,在我的第一个程序中遇到了一个问题,请您帮助我,并提前表示感谢

它打印评论

Hibernate: 

/* insert testhybernate1.Employee

*/ insert 
    into
        employee1
        (ename, mobile, email, id) 
    values
        (?, ?, ?, ?)
并给出了错误:-

org.postgresql.util.PSQLException: ERROR: relation "employee1" does not exist
我补充说

<property name="hibernate.hbm2ddl.auto">create</property> 
我的应用程序类Hybernate1.java

package testhybernate1;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class Hybernate1 {

@SuppressWarnings("deprecation")
public static void main(String[] args) {
    System.out.println("starting........");
    Configuration cfg= new Configuration();
//  cfg.configure();
    try
    {
        cfg.configure();
    }
    catch(Exception e)
    {
        System.out.println("*** Exception while configuring:"+e);
    }
    SessionFactory sf=null;
    try
    {
    //  SessionFactory sf=new SessionFactory(cfg);
        sf=cfg.buildSessionFactory();
    }
    catch(Exception e)
    {
        System.out.println("exception in creating sessionfactory :"+e);

    }
    if(sf.equals(null))
    return;
    else
    {
        Session s=sf.openSession();

        Transaction tx = s.beginTransaction();

        Employee emp=new Employee();
        emp.setId(1);
        emp.setEname("Raghav");
        emp.setMobile(95899);
        emp.setEmail("k123@mail");


        Integer eid=(Integer)s.save(emp);
        //s.flush();
        tx.commit();
        s.close();
        System.out.println("emp id in database="+eid);

    }
    // TODO Auto-generated method stub

}

}
对不起,我的错误

我得到了答案,在我的配置文件中应该有

<property name="hibernate.connection.url">jdbc:postgresql:postgres</property>
jdbc:postgresql:postgres
而不是

<property name="hibernate.connection.url">jdbc:postgresql:template1</property>
jdbc:postgresql:template1
package testhybernate1;

import java.io.Serializable;

public class Employee implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = 1L;
private int id;
private String ename;
private long mobile;
private String email;

public Employee(){}

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getEname() {
    return ename;
}

public void setEname(String ename) {
    this.ename = ename;
}

public long getMobile() {
    return mobile;
}

public void setMobile(long mobile) {
    this.mobile = mobile;
}

public String getEmail() {
    return email;
}

public void setEmail(String email) {
    this.email = email;
}



}
package testhybernate1;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class Hybernate1 {

@SuppressWarnings("deprecation")
public static void main(String[] args) {
    System.out.println("starting........");
    Configuration cfg= new Configuration();
//  cfg.configure();
    try
    {
        cfg.configure();
    }
    catch(Exception e)
    {
        System.out.println("*** Exception while configuring:"+e);
    }
    SessionFactory sf=null;
    try
    {
    //  SessionFactory sf=new SessionFactory(cfg);
        sf=cfg.buildSessionFactory();
    }
    catch(Exception e)
    {
        System.out.println("exception in creating sessionfactory :"+e);

    }
    if(sf.equals(null))
    return;
    else
    {
        Session s=sf.openSession();

        Transaction tx = s.beginTransaction();

        Employee emp=new Employee();
        emp.setId(1);
        emp.setEname("Raghav");
        emp.setMobile(95899);
        emp.setEmail("k123@mail");


        Integer eid=(Integer)s.save(emp);
        //s.flush();
        tx.commit();
        s.close();
        System.out.println("emp id in database="+eid);

    }
    // TODO Auto-generated method stub

}

}
<property name="hibernate.connection.url">jdbc:postgresql:postgres</property>
<property name="hibernate.connection.url">jdbc:postgresql:template1</property>