116 lines
2.7 KiB
Java
116 lines
2.7 KiB
Java
package com.andrewkydev.database.config;
|
|
|
|
import com.andrewkydev.database.schema.SqlDialect;
|
|
|
|
public final class DatabaseConfig {
|
|
private final SqlDialect dialect;
|
|
private final String host;
|
|
private final int port;
|
|
private final String database;
|
|
private final String username;
|
|
private final String password;
|
|
private final String adminDatabase;
|
|
private final PoolConfig pool;
|
|
private final boolean autoTransactions;
|
|
|
|
public DatabaseConfig(
|
|
SqlDialect dialect,
|
|
String host,
|
|
int port,
|
|
String database,
|
|
String username,
|
|
String password,
|
|
String adminDatabase,
|
|
PoolConfig pool,
|
|
boolean autoTransactions
|
|
) {
|
|
this.dialect = dialect;
|
|
this.host = host;
|
|
this.port = port;
|
|
this.database = database;
|
|
this.username = username;
|
|
this.password = password;
|
|
this.adminDatabase = adminDatabase;
|
|
this.pool = pool;
|
|
this.autoTransactions = autoTransactions;
|
|
}
|
|
|
|
public SqlDialect dialect() {
|
|
return dialect;
|
|
}
|
|
|
|
public String host() {
|
|
return host;
|
|
}
|
|
|
|
public int port() {
|
|
return port;
|
|
}
|
|
|
|
public String database() {
|
|
return database;
|
|
}
|
|
|
|
public String username() {
|
|
return username;
|
|
}
|
|
|
|
public String password() {
|
|
return password;
|
|
}
|
|
|
|
public String adminDatabase() {
|
|
return adminDatabase;
|
|
}
|
|
|
|
public PoolConfig pool() {
|
|
return pool;
|
|
}
|
|
|
|
public boolean autoTransactions() {
|
|
return autoTransactions;
|
|
}
|
|
|
|
public static final class PoolConfig {
|
|
private final int maxPoolSize;
|
|
private final int minIdle;
|
|
private final long connectionTimeoutMs;
|
|
private final long idleTimeoutMs;
|
|
private final long maxLifetimeMs;
|
|
|
|
public PoolConfig(
|
|
int maxPoolSize,
|
|
int minIdle,
|
|
long connectionTimeoutMs,
|
|
long idleTimeoutMs,
|
|
long maxLifetimeMs
|
|
) {
|
|
this.maxPoolSize = maxPoolSize;
|
|
this.minIdle = minIdle;
|
|
this.connectionTimeoutMs = connectionTimeoutMs;
|
|
this.idleTimeoutMs = idleTimeoutMs;
|
|
this.maxLifetimeMs = maxLifetimeMs;
|
|
}
|
|
|
|
public int maxPoolSize() {
|
|
return maxPoolSize;
|
|
}
|
|
|
|
public int minIdle() {
|
|
return minIdle;
|
|
}
|
|
|
|
public long connectionTimeoutMs() {
|
|
return connectionTimeoutMs;
|
|
}
|
|
|
|
public long idleTimeoutMs() {
|
|
return idleTimeoutMs;
|
|
}
|
|
|
|
public long maxLifetimeMs() {
|
|
return maxLifetimeMs;
|
|
}
|
|
}
|
|
}
|