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

com.redislabs.riot.db.DataSourceOptions Maven / Gradle / Ivy

The newest version!
package com.redislabs.riot.db;

import lombok.Data;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import picocli.CommandLine.Option;

import javax.sql.DataSource;

@Data
public class DataSourceOptions {

    @Option(names = "--driver", description = "Fully qualified name of the JDBC driver", paramLabel = "")
    private String driver;
    @Option(names = "--url", required = true, description = "JDBC URL to connect to the database", paramLabel = "")
    private String url;
    @Option(names = "--username", description = "Login username of the database", paramLabel = "")
    private String username;
    @Option(names = "--password", arity = "0..1", interactive = true, description = "Login password of the database", paramLabel = "")
    private String password;

    public DataSource dataSource() {
        DataSourceProperties properties = new DataSourceProperties();
        properties.setUrl(url);
        properties.setDriverClassName(driver);
        properties.setUsername(username);
        properties.setPassword(password);
        return properties.initializeDataSourceBuilder().build();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy