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

com.sap.cloud.mt.runtime.DataSourceCreatorHikari Maven / Gradle / Ivy

There is a newer version: 3.3.3
Show newest version
/******************************************************************************
 * © 2020 SAP SE or an SAP affiliate company. All rights reserved.            *
 ******************************************************************************/
package com.sap.cloud.mt.runtime;

import com.sap.cloud.mt.runtime.DataPoolSettings.Parameter;
import com.sap.cloud.mt.subscription.DataSourceInfo;
import com.sap.cloud.mt.subscription.exceptions.InternalError;
import com.zaxxer.hikari.HikariDataSource;

import javax.sql.DataSource;
import java.util.stream.Stream;

public class DataSourceCreatorHikari extends DataSourceCreator {
    private final DataPoolSettings poolSettings;

    public DataSourceCreatorHikari(DataPoolSettings poolSettings) {
        this.poolSettings = poolSettings;
    }

    @Override
    protected DataSource build(DataSourceInfo info, EnvironmentAccess env) throws InternalError {
        HikariDataSource hikariDataSource = new HikariDataSource();
        hikariDataSource.setDriverClassName(info.getDriver());
        hikariDataSource.setJdbcUrl(info.getUrl());
        hikariDataSource.setUsername(info.getUser());
        hikariDataSource.setPassword(info.getPassword());
        return hikariDataSource;
    }

    @Override
    protected Stream getPoolParameters() {
        return poolSettings.getHikariParameters();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy