title: HikariCP connection timeout error after certain amount of queries
body: <p>Before I get started, I'd like to say I've checked the following and they didn't help me:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/33816105/hikaricp-connection-error">HikariCP connection error</a></li>
  <li><a href="https://stackoverflow.com/questions/32968530/hikaricp-connection-is-not-available">HikariCP - connection is not available</a></li>
  <li><a href="https://github.com/brettwooldridge/HikariCP/issues/104" rel="noreferrer">https://github.com/brettwooldridge/HikariCP/issues/104</a></li>
  </ul>
  
  <p>Essentially, I'm getting a HikariCP stracktrace and I don't know what's causing it.</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>I've tried changing the <code>maximum pool size</code>, <code>minimum idle</code> and I've also enabled the <code>leak detection</code> (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.</p>
  
  <p>This is my current configuration:</p>
  
  <pre><code>    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);
  </code></pre>
  
  <p>My query methods are structured as following:</p>
  
  <pre><code>        // 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();
  </code></pre>
  
  <p>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.</p>