刚开始学习Hibernate 为什么这里就报错了啊
importjava.sql.Date;importorg.hibernate.Session;importorg.hibernate.SessionFactory;im...
import java.sql.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.junit.Test;
public class HibernateTest {
@Test
public void test() {
System.out.println("test...");
SessionFactory sessionFactory = null;
Configuration configuration = new Configuration().configure();
ServiceRegistry serviceRegistry =
new ServiceRegistryBuilder().applySettings(configuration.getProperties())
.buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);//程序在这报错
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
News news = new News("Java12345", "ATGUIGU", new Date(new java.util.Date().getTime()));
session.save(news);
transaction.commit();
session.close();
sessionFactory.close();
} 展开
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.junit.Test;
public class HibernateTest {
@Test
public void test() {
System.out.println("test...");
SessionFactory sessionFactory = null;
Configuration configuration = new Configuration().configure();
ServiceRegistry serviceRegistry =
new ServiceRegistryBuilder().applySettings(configuration.getProperties())
.buildServiceRegistry();
sessionFactory = configuration.buildSessionFactory(serviceRegistry);//程序在这报错
Session session = sessionFactory.openSession();
Transaction transaction = session.beginTransaction();
News news = new News("Java12345", "ATGUIGU", new Date(new java.util.Date().getTime()));
session.save(news);
transaction.commit();
session.close();
sessionFactory.close();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询