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

org.n3r.eql.trans.EqlHikariConnection Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
package org.n3r.eql.trans;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import lombok.SneakyThrows;
import lombok.val;
import org.n3r.eql.config.EqlConfig;
import org.n3r.eql.util.EqlUtils;
import org.n3r.eql.util.O;

import java.sql.Connection;

public class EqlHikariConnection extends AbstractEqlConnection {
    HikariDataSource dataSource;

    @Override
    public void initialize(EqlConfig eqlConfig) {
        val params = eqlConfig.params();
        EqlUtils.compatibleWithUserToUsername(params);

        val config = new HikariConfig();
        O.populate(config, params);

        dataSource = new HikariDataSource(config);
    }

    @Override @SneakyThrows
    public Connection getConnection(String dbName) {
        return dataSource.getConnection();
    }

    @Override
    public void destroy() {
        dataSource.close();
    }

    @Override
    public String getDriverName() {
        return EqlUtils.getDriverNameFromConnection(dataSource);
    }

    @Override
    public String getJdbcUrl() {
        return dataSource.getJdbcUrl();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy