private String getNameFromDB(String id) throws IOException { try { Connection conn = dbConnectionPool.getConnection(); try { PreparedStatement statement = conn.prepareStatement("SELECT name FROM tenants WHERE id=? AND deleted=false "); try { statement.setString(1, id); return dbQueryExecutor.getString(statement); } finally { statement.close(); } } finally { conn.close(); } } catch (SQLException e) { LOG.error("Exception getting name of tenant {}", id); throw new IOException(e); } }