Properly closed jdbc:mysql connections to prevent exception

MySQLNonTransientConnectionException: Too many connections