package com.demo.dao.utils; import java.beans.PropertyVetoException; import java.sql.SQLException; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.TransactionManagementConfigurer; import com.mchange.v2.c3p0.ComboPooledDataSource; /** * Data source tool class * * @author Xiong Jiajia * */ @Configuration @PropertySource("classpath:/application.properties") public class DataSourceConfiguration{ @Autowired private Environment props; @Bean(name = "dataSource") public ComboPooledDataSource dataSource() throws PropertyVetoException, SQLException { ComboPooledDataSource dataSource = new ComboPooledDataSource(); dataSource.setDriverClass(props.getProperty("jdbc.driver")); dataSource.setJdbcUrl(props.getProperty("jdbc.url")); dataSource.setUser(props.getProperty("jdbc.username")); dataSource.setPassword(props.getProperty("jdbc.password")); dataSource.setMaxPoolSize(40); dataSource.setMinPoolSize(2); dataSource.setInitialPoolSize(10); dataSource.setMaxStatements(20); return dataSource; } }
data source
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326413846&siteId=291194637
Recommended
Ranking