現在、私のメインデータベースに接続するオープンプールが1つあり、完全に機能します。しかし今、私は別のデータベース用の新しいプールを開こうとしています。私は新しいプールをセットアップしました。最初のセットアップはどうでしょうか、データベース名の編集などはどうでもいいです。setupHikari()メソッドをロードするとエラーは表示されませんが、実際のステートメントが実行されるとエラーが発生します。com.zaxxer.hikari.pool.PoolInitializationException:プール初期化時の例外
Caused by: com.zaxxer.hikari.pool.PoolInitializationException: Exception during pool initialization at com.zaxxer.hikari.pool.HikariPool.initializeConnections(HikariPool.java:580) ~[?:?] at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:150) ~[?:?] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96) ~[?:?] at com.thecodexmc.GameLibrary.xenforo.XenUtils.getUserGroupID(XenUtils.java:51) ~[?:?] at com.thecodexmc.GameLibrary.game.GameListeners.onLogin(GameListeners.java:334) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] ... 13 more Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Too many connections at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_79] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_79] at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_79] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.Util.getInstance(Util.java:382) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1013) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:931) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:4031) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1296) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2338) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2371) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2163) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:794) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[?:1.7.0_79] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.7.0_79] at java.lang.reflect.Constructor.newInstance(Constructor.java:526) ~[?:1.7.0_79] at com.mysql.jdbc.Util.handleNewInstance(Util.java:407) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:378) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:305) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:440) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:138) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.mysql.jdbc.jdbc2.optional.MysqlDataSource.getConnection(MysqlDataSource.java:108) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] at com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:495) ~[?:?] at com.zaxxer.hikari.pool.HikariPool.initializeConnections(HikariPool.java:564) ~[?:?] at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:150) ~[?:?] at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:96) ~[?:?] at com.thecodexmc.GameLibrary.xenforo.XenUtils.getUserGroupID(XenUtils.java:51) ~[?:?] at com.thecodexmc.GameLibrary.game.GameListeners.onLogin(GameListeners.java:334) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_79] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_79] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-PaperSpigot-7aa4900-62a2169] ... 13 more
私はここで間違っていますか?ここに私のXenSQLクラスがありますが、それが問題の原因です。
public class XenSQL {
private static XenSQL instance;
private HikariDataSource hikari;
public XenSQL() {
instance = this;
}
public void setupHikari() {
hikari = new HikariDataSource();
hikari.setMaximumPoolSize(10);
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
hikari.addDataSourceProperty("serverName", host);
hikari.addDataSourceProperty("port", port);
hikari.addDataSourceProperty("databaseName", database);
hikari.addDataSourceProperty("user", user);
hikari.addDataSourceProperty("password", password);
System.out.println("[XenSQL] HikariCP connected to the database successfully.");
}
public void queryUpdate(String query) {
Connection connection = null;
try {
connection = hikari.getConnection();
PreparedStatement pre = connection.prepareStatement(query);
pre.executeUpdate();
pre.close();
} catch (SQLException e) {
System.out.println("[XenSQL] Error whilst executing the query \"" + query + "\": " + e.getMessage());
} finally {
closeConnection(connection);
}
}
public void closeConnection(Connection connection) {
if(connection != null) {
try {
connection.close();
} catch(SQLException e) {
e.printStackTrace();
}
}
}
public HikariDataSource getHikari() {
return hikari;
}
public static XenSQL getInstance() {
return instance;
}
}
明白な理由からSQL情報を削除しましたが、ここで何が問題なのか分かりません。 MySQLNonTransientConnectionExceptionについては
可能性があることも通常の方法ではなく、一つの長い行として –