code: private int getNumObjectsWithVersion(Connection conn, int n)
              throws SQLException {
  
          PreparedStatement st = null;
          try {
              String query;
              // Because we are dealing with only two Strings, one of which is fixed,
              // take advantage of String.concat
              if (n > 0) {
                  query = "SELECT COUNT(*) FROM doRegistry WHERE systemVersion = ".concat(Integer.toString(n));
              } else {
                  query = "SELECT COUNT(*) FROM doRegistry";
              }
              st = conn.prepareStatement(query);
              ResultSet results = st.executeQuery();
              results.next();
              return results.getInt(1);
          } finally {
              if (st != null) {
                  st.close();
              }
          }
      }
docs: Get the number of objects in the registry whose system version is equal
  to the given value. If n is less than one, return the total number of
  objects in the registry.