Before I get started, I'd like to say I've checked the following and they didn't help me:
- HikariCP connection error
- HikariCP - connection is not available
- https://github.com/brettwooldridge/HikariCP/issues/104
Essentially, I'm getting a HikariCP stracktrace and I don't know what's causing it.
java.sql.SQLTransientConnectionException: HikariPool-1 - Connection is not available, request timed out after 30000ms.
at com.zaxxer.hikari.pool.HikariPool.createTimeoutException(HikariPool.java:548)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:186)
at com.zaxxer.hikari.pool.HikariPool.getConnection(HikariPool.java:145)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:83)
at de.arraying.Arraybot.managers.ManagerSync.addCustomCommand(ManagerSync.java:192)
at de.arraying.Arraybot.commands.CommandsCommand.onCommand(CommandsCommand.java:100)
at de.arraying.Arraybot.commands.Command.execute(Command.java:72)
at de.arraying.Arraybot.listeners.ListenerChat.onGuildMessageReceived(ListenerChat.java:68)
at net.dv8tion.jda.core.hooks.ListenerAdapter.onEvent(ListenerAdapter.java:299)
at net.dv8tion.jda.core.hooks.InterfacedEventManager.handle(InterfacedEventManager.java:64)
at net.dv8tion.jda.core.handle.MessageCreateHandler.handleDefaultMessage(MessageCreateHandler.java:97)
at net.dv8tion.jda.core.handle.MessageCreateHandler.handleInternally(MessageCreateHandler.java:47)
at net.dv8tion.jda.core.handle.SocketHandler.handle(SocketHandler.java:38)
at net.dv8tion.jda.core.requests.WebSocketClient.handleEvent(WebSocketClient.java:688)
at net.dv8tion.jda.core.requests.WebSocketClient.onTextMessage(WebSocketClient.java:437)
at com.neovisionaries.ws.client.ListenerManager.callOnTextMessage(ListenerManager.java:352)
at com.neovisionaries.ws.client.ReadingThread.callOnTextMessage(ReadingThread.java:262)
at com.neovisionaries.ws.client.ReadingThread.callOnTextMessage(ReadingThread.java:240)
at com.neovisionaries.ws.client.ReadingThread.handleTextFrame(ReadingThread.java:965)
at com.neovisionaries.ws.client.ReadingThread.handleFrame(ReadingThread.java:748)
at com.neovisionaries.ws.client.ReadingThread.main(ReadingThread.java:110)
at com.neovisionaries.ws.client.ReadingThread.run(ReadingThread.java:66)
I've tried changing the maximum pool size
, minimum idle
and I've also enabled the leak detection
(at 2s). None of these helped, except that I am getting a leak detection every time I execute a query, so maybe it's related to this.
This is my current configuration:
HikariConfig hikariConfig = new HikariConfig();
hikariConfig.setJdbcUrl("jdbc:mysql://"+url+":3306/"+database+"?useSSL=false");
hikariConfig.setUsername(username);
hikariConfig.setPassword(password);
hikariConfig.setMaximumPoolSize(10);
hikariConfig.setMinimumIdle(3);
hikariConfig.setLeakDetectionThreshold(2000);
dataSource = new HikariDataSource(hikariConfig);
My query methods are structured as following:
// inside a try/catch, after some checks that aren't related.
PreparedStatement preparedStatement =
dataSource.getConnection().prepareStatement(query);
preparedStatement.setString(2, id);
preparedStatement.setString(3, name);
preparedStatement.setObject(1, value);
preparedStatement.executeUpdate();
preparedStatement.close();
Am I supposed to close the connection after this or something? The only thing I can imagine that might cause an error are memory leaks, and I don't think I have any. My CPU usage is fine, too, and so is my internet connection. The queries all work perfectly fine, except for the fact that that just start throwing this error after a few times.