code: public void checkDataBase(boolean autoRepair)
     {
        SecurityHelper.validateSecurityPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION);
  
        Connection jdbcConn = null;
        try
        {
           jdbcConn = jdbcDataContainer.getConnectionFactory().getJdbcConnection();
  
           for (InspectionQuery query : itemsInspectionQuery)
           {
              PreparedStatement st = null;
              ResultSet resultSet = null;
              try
              {
                 st = jdbcConn.prepareStatement(query.getStatement());
  
                 resultSet = st.executeQuery();
                 if (resultSet.next())
                 {
                    logDescription(query.getDescription());
  
                    do
                    {
                       logBrokenObjectAndSetInconsistency(getBrokenObject(resultSet, query.getFieldNames()));
                       if (autoRepair)
                       {
                          try
                          {
                             query.getRepair().doRepair(resultSet);
                             logComment("Inconsistency has been fixed");
                          }
                          catch (SQLException e)
                          {
                             logExceptionAndSetInconsistency("Inconsistency can not been fixed", e);
                          }
                       }
                    }
                    while (resultSet.next());
                 }
              }
              finally
              {
                 JDBCUtils.freeResources(resultSet, st, null);
              }
           }
        }
        catch (SQLException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during DB checking.", e);
        }
        catch (RepositoryException e)
        {
           logExceptionAndSetInconsistency("Unexpected exception during DB checking.", e);
        }
        finally
        {
           JDBCUtils.freeResources(null, null, jdbcConn);
        }
     }
docs: Check database.
  <p>
  Check that database is not broken, and all base relation between jcr-items are not corrupted.
  </p>