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

com.despegar.jdbc.galera.GaleraDB Maven / Gradle / Ivy

Go to download

A simple Java client for MariaDB Galera Cluster and Percona XtraDB Cluster. It is designed to be an alternative to connect JVM app to MariaDB/Percona galera nodes without HAProxy

There is a newer version: 1.0.20
Show newest version
package com.despegar.jdbc.galera;

import com.google.common.base.MoreObjects;

import javax.annotation.Nonnull;

public class GaleraDB {
    public static final String MYSQL_URL_PREFIX = "jdbc:mysql://";
    public static final String MYSQL_URL_SEPARATOR = "/";

    public final String jdbcUrlPrefix;
    public final String jdbcUrlSeparator;
    public final String database;
    public final String user;
    public final String password;

    public GaleraDB(@Nonnull String database, @Nonnull String user, @Nonnull String password) {
        this(database, user, password, MYSQL_URL_PREFIX, MYSQL_URL_SEPARATOR);
    }

    public GaleraDB(@Nonnull String database, @Nonnull String user, @Nonnull String password, @Nonnull String jdbcUrlPrefix, @Nonnull String jdbcUrlSeparator) {
        this.database = database;
        this.user = user;
        this.password = password;
        this.jdbcUrlPrefix = jdbcUrlPrefix;
        this.jdbcUrlSeparator = jdbcUrlSeparator;
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .omitNullValues()
                .add("jdbcUrlPrefix", jdbcUrlPrefix)
                .add("jdbcUrlSeparator", jdbcUrlSeparator)
                .add("database", database)
                .add("user", user)
                .toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy