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

com.jeesuite.mybatis.datasource.builder.HikariCPDataSourceBuilder Maven / Gradle / Ivy

There is a newer version: 1.4.0
Show newest version
package com.jeesuite.mybatis.datasource.builder;

import java.util.Properties;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;

import com.zaxxer.hikari.HikariDataSource;

public class HikariCPDataSourceBuilder {

	public static BeanDefinitionBuilder builder(Properties props){
		
		BeanDefinitionBuilder beanDefinitionBuilder =  BeanDefinitionBuilder.genericBeanDefinition(HikariDataSource.class);
		if(props.containsKey("driverClassName"))beanDefinitionBuilder.addPropertyValue("driverClassName", props.getProperty("driverClassName"));
    	beanDefinitionBuilder.addPropertyValue("jdbcUrl", props.getProperty("jdbcUrl"));
    	beanDefinitionBuilder.addPropertyValue("username", props.getProperty("username"));
    	beanDefinitionBuilder.addPropertyValue("password", props.getProperty("password"));
    	beanDefinitionBuilder.addPropertyValue("connectionTestQuery", props.getProperty("connectionTestQuery","SELECT 'x'"));
    	beanDefinitionBuilder.addPropertyValue("connectionTimeout", Long.parseLong(props.getProperty("connectionTimeout","10000")));
    	beanDefinitionBuilder.addPropertyValue("idleTimeout", Long.parseLong(props.getProperty("idleTimeout","600000")));
    	beanDefinitionBuilder.addPropertyValue("maximumPoolSize", Integer.parseInt(props.getProperty("maximumPoolSize","10")));
    	beanDefinitionBuilder.addPropertyValue("maxLifetime", Long.parseLong(props.getProperty("maxLifetime","900000")));
    	return beanDefinitionBuilder;
        
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy