快速配置DataSource

import org.apache.commons.dbcp.BasicDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

        String url = "jdbc:mysql://localhost:3306/cdc_dmap_dev?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull";  
        BasicDataSource dataSource = new BasicDataSource();
        dataSource.setDriverClassName("com.mysql.jdbc.Driver");  
        dataSource.setUrl(url);  
        dataSource.setUsername("root");  
        dataSource.setPassword("hao123"); 

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

 

你可能感兴趣的:(dataSource)