2018-10-24Spring 多种数据库连接池配置

xml配置文件(多种方式)




    
    

    
    
    
    
    
    
        
        
        
        
    
    
    
    
    
        
    



java测试类

package com.hello.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;



@ContextConfiguration("classpath:applicationContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringTest {
    
    @Autowired
    private JdbcTemplate jdbcTemplate;
    
    @Test
    public void run() {
    
        jdbcTemplate.update("insert into tb_user values (null, ?, ?)", "cuihua2", 10.24);
    }
    

    
}

你可能感兴趣的:(2018-10-24Spring 多种数据库连接池配置)