为了账号安全,请及时绑定邮箱和手机立即绑定

No appropriate connection provider encountered, assuming application will be supplying connections

2018-9-10 16:53:34 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
2018-9-10 16:53:34 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.4.Final}
2018-9-10 16:53:34 org.hibernate.cfg.Environment <clinit>
INFO: HHH000205: Loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false}
2018-9-10 16:53:34 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
2018-9-10 16:53:34 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator initiateService
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections


这是测试类运行的结果,这是什么问题呀

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.After;
import org.junit.Before;
import org.junit.Test;

import com.model.TUser;

public class test11 {
    private SessionFactory sessionFactory;
    private Session session;
    private Transaction transaction;
    @Before
    public void init() {
        // 创建配置对象
        Configuration config = new Configuration();
        // 创建服务注册对象
        ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
        // 创建会话工厂对象
        sessionFactory = config.buildSessionFactory(serviceRegistry);
        // 会话对象
        session = sessionFactory.openSession();
        // 开启事务
        transaction = session.beginTransaction();        
    }

    @After
    public void destroy() {
        
        session.close();// 关闭会话
        sessionFactory.close();
    }

    @Test
    public void testSaveUser() {
        // 生成用户对象
        TUser u = new TUser(10, "liu", "liuliu", "1234567", "beijing", "女", 123456);
        transaction.begin();
        // 保存对象进入数据库
        session.save(u);
        transaction.commit();// 提交事务
    }
}


正在回答

1 回答

init()方法里面Configuration config = new Configuration().configture();

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

No appropriate connection provider encountered, assuming application will be supplying connections

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信