mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Don't try to set unicode connection properties for PostgreSQL (#1134)
This commit is contained in:
parent
43d04a97f5
commit
526448ce40
@ -34,6 +34,7 @@ import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -50,8 +51,8 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void appendProperties(HikariConfig config, StorageCredentials credentials) {
|
protected void appendProperties(HikariConfig config, Map<String, String> properties) {
|
||||||
for (Map.Entry<String, String> property : credentials.getProperties().entrySet()) {
|
for (Map.Entry<String, String> property : properties.entrySet()) {
|
||||||
config.addDataSourceProperty(property.getKey(), property.getValue());
|
config.addDataSourceProperty(property.getKey(), property.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +77,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
config.setPoolName("luckperms-hikari");
|
config.setPoolName("luckperms-hikari");
|
||||||
|
|
||||||
appendConfigurationInfo(config);
|
appendConfigurationInfo(config);
|
||||||
appendProperties(config, this.configuration);
|
appendProperties(config, new HashMap<>(this.configuration.getProperties()));
|
||||||
|
|
||||||
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
config.setMaximumPoolSize(this.configuration.getMaxPoolSize());
|
||||||
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
config.setMinimumIdle(this.configuration.getMinIdleConnections());
|
||||||
|
@ -30,7 +30,6 @@ import com.zaxxer.hikari.HikariConfig;
|
|||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -50,13 +49,12 @@ public class MariaDbConnectionFactory extends HikariConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(HikariConfig config, StorageCredentials credentials) {
|
protected void appendProperties(HikariConfig config, Map<String, String> properties) {
|
||||||
Set<Map.Entry<String, String>> properties = credentials.getProperties().entrySet();
|
|
||||||
if (properties.isEmpty()) {
|
if (properties.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String propertiesString = properties.stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(";"));
|
String propertiesString = properties.entrySet().stream().map(e -> e.getKey() + "=" + e.getValue()).collect(Collectors.joining(";"));
|
||||||
|
|
||||||
// kinda hacky. this will call #setProperties on the datasource, which will append these options
|
// kinda hacky. this will call #setProperties on the datasource, which will append these options
|
||||||
// onto the connections.
|
// onto the connections.
|
||||||
|
@ -29,6 +29,7 @@ import com.zaxxer.hikari.HikariConfig;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class MySqlConnectionFactory extends HikariConnectionFactory {
|
public class MySqlConnectionFactory extends HikariConnectionFactory {
|
||||||
@ -47,20 +48,20 @@ public class MySqlConnectionFactory extends HikariConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendProperties(HikariConfig config, StorageCredentials credentials) {
|
protected void appendProperties(HikariConfig config, Map<String, String> properties) {
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
properties.putIfAbsent("cachePrepStmts", "true");
|
||||||
config.addDataSourceProperty("alwaysSendSetIsolation", "false");
|
properties.putIfAbsent("alwaysSendSetIsolation", "false");
|
||||||
config.addDataSourceProperty("cacheServerConfiguration", "true");
|
properties.putIfAbsent("cacheServerConfiguration", "true");
|
||||||
config.addDataSourceProperty("elideSetAutoCommits", "true");
|
properties.putIfAbsent("elideSetAutoCommits", "true");
|
||||||
config.addDataSourceProperty("useLocalSessionState", "true");
|
properties.putIfAbsent("useLocalSessionState", "true");
|
||||||
|
|
||||||
config.addDataSourceProperty("useServerPrepStmts", "true");
|
properties.putIfAbsent("useServerPrepStmts", "true");
|
||||||
config.addDataSourceProperty("prepStmtCacheSize", "250");
|
properties.putIfAbsent("prepStmtCacheSize", "250");
|
||||||
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
|
properties.putIfAbsent("prepStmtCacheSqlLimit", "2048");
|
||||||
config.addDataSourceProperty("cacheCallableStmts", "true");
|
properties.putIfAbsent("cacheCallableStmts", "true");
|
||||||
|
|
||||||
// append configurable properties
|
// append configurable properties
|
||||||
super.appendProperties(config, credentials);
|
super.appendProperties(config, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -29,6 +29,7 @@ import com.zaxxer.hikari.HikariConfig;
|
|||||||
|
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class PostgreConnectionFactory extends HikariConnectionFactory {
|
public class PostgreConnectionFactory extends HikariConnectionFactory {
|
||||||
@ -41,6 +42,15 @@ public class PostgreConnectionFactory extends HikariConnectionFactory {
|
|||||||
return "PostgreSQL";
|
return "PostgreSQL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(HikariConfig config, Map<String, String> properties) {
|
||||||
|
// remove the default config properties which don't exist for PostgreSQL
|
||||||
|
properties.remove("useUnicode");
|
||||||
|
properties.remove("characterEncoding");
|
||||||
|
|
||||||
|
super.appendProperties(config, properties);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void appendConfigurationInfo(HikariConfig config) {
|
protected void appendConfigurationInfo(HikariConfig config) {
|
||||||
String address = this.configuration.getAddress();
|
String address = this.configuration.getAddress();
|
||||||
|
Loading…
Reference in New Issue
Block a user