注册 登录
编程论坛 J2EE论坛

在eclipse中应用hibernate来连接数据库时出现这样的问题!!!求高手

尘埃落雪 发布于 2011-09-05 22:34, 600 次点击
这是出现问题是显示的错误信息:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    SessionFactory cannot be resolved to a type
    Configuration cannot be resolved to a type
    Session cannot be resolved to a type
    Transaction cannot be resolved to a type
    HibernateException cannot be resolved to a type

以下
这是测试用的java文件:
package ch03.hibernate;

import org.hibernate.*;
import org.hibernate.cfg.*;

public class Test {
        
    public static void main(String[] args)
    {
        try
        {
            SessionFactory sf=new Configuration().configure().buildSessionFactory();
            Session session=sf.openSession();
            
            Transaction tx=session.beginTransaction();
            User user=new User();
            user.setUsername("Hibernate");
            user.setPassword("123");
            session.save(user);
            
            ();
            
            session.close();
               
        }catch(HibernateException e)
        {
                e.printStackTrace();
            
        }
    }
}
这是什么问题造成的呢???
0 回复
1