All Downloads are FREE. Search and download functionalities are using the official Maven repository.

qunar.tc.qmq.jdbc.DefaultDataSourceFactory Maven / Gradle / Ivy

The newest version!
package qunar.tc.qmq.jdbc;

import javax.sql.DataSource;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import qunar.tc.qmq.configuration.DynamicConfig;

public class DefaultDataSourceFactory implements DataSourceFactory {

	@Override
	public DataSource createDataSource(DynamicConfig config) {
		final HikariConfig cpConfig = new HikariConfig();
		cpConfig.setDriverClassName(config.getString("jdbc.driverClassName", "com.mysql.jdbc.Driver"));
		cpConfig.setJdbcUrl(config.getString("jdbc.url"));
		cpConfig.setUsername(config.getString("jdbc.username"));
		cpConfig.setPassword(config.getString("jdbc.password"));
		cpConfig.setMaximumPoolSize(config.getInt("pool.size.max", 10));

		return new HikariDataSource(cpConfig);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy