AWS RDS PostgreSQL error "remaining connection slots are reserved for non-replication superuser connections"
<p>In the dashboard I see there are currently 22 open connections to the DB instance, blocking new connections with the error: </p>

<blockquote>
  <p>remaining connection slots are reserved for non-replication superuser connections.</p>
</blockquote>

<p>I'm accessing the DB from web service API running on EC2 instance and always keep the best practise of:</p>

<pre><code>Connection connection = DriverManager.getConnection(URL, USER_NAME, PASSWORD);
Class.forName(DB_CLASS);
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(SQL_Query_String);
...
resultSet.close();
statement.close();
connection.close();
</code></pre>

<ol>
<li><p>Can I do something else in the code?</p></li>
<li><p>Should I do something else in the DB management?</p></li>
<li><p>Is there a way to periodically close connections?</p></li>
</ol>