Returns the user driver for a given database context.<p>

@param dbc the database context

@return the user driver for the database context
175719
public I_CmsUserDriver getUserDriver(CmsDbContext dbc) {

        if ((dbc == null) || (dbc.getProjectId() == null) || dbc.getProjectId().isNullUUID()) {
            return m_userDriver;
        }
        I_CmsUserDriver driver = dbc.getUserDriver(dbc.getProjectId());
        return driver != null ? driver : m_userDriver;

    }
161566
public void setupJDBCConnection(String strJdbcDriver) throws DBException
    {
        if (m_JDBCConnection != null)
            return;

        if (firstTime == null)
        	firstTime = new Date();
    	if (m_classDB == null)
    	{
	        synchronized (firstTime)
	        {
	        	if (m_classDB == null)
	        		m_classDB = ClassServiceUtility.getClassService().makeObjectFromClassName(strJdbcDriver);
	        }
    	}
        Utility.getLogger().info("Driver found: " + (m_classDB != null));
        m_JDBCConnection = this.getJDBCConnection();    // Setup the initial connection
    }
1068385
public <C> DbxDeltaC<C> getDeltaCWithPathPrefix(Collector<DbxDeltaC.Entry<DbxEntry>, C> collector,
                                                    /*@Nullable*/String cursor, String pathPrefix)
        throws DbxException
    {
        return getDeltaCWithPathPrefix(collector, cursor, pathPrefix, false);
    }
409648
public List<CmsResource> getUsersPubList(CmsDbContext dbc, CmsUUID userId) throws CmsDataAccessException {

        synchronized (m_publishListUpdateLock) {
            updateLog(dbc);
            return m_projectDriver.getUsersPubList(dbc, userId);
        }
    }
813979
public synchronized Connection getConnection() throws DatabaseException {
        initialize();
        Connection conn = null;
        try {
            conn = DriverManager.getConnection(connectionString, userName, password);
        } catch (SQLException ex) {
            LOGGER.debug("", ex);
            throw new DatabaseException("Unable to connect to the database", ex);
        }
        return conn;
    }
659717
protected CmsUUID createWebusersGroup(CmsSetupDb dbCon) throws SQLException {

        String sql = readQuery(QUERY_CREATE_WEBUSERS_GROUP);
        List<Object> params = new ArrayList<Object>();
        CmsUUID id = new CmsUUID();
        params.add(id.toString());
        params.add(CmsUUID.getNullUUID().toString());
        params.add("allWebusersFromUpgrade6to7");
        params.add(
            "This group was created by the OpenCms Upgrade Wizard to facilitate the handling of former called WebUsers, can be deleted if needed.");
        params.add(new Integer(0));
        params.add("/");
        dbCon.updateSqlStatement(sql, null, params);
        return id;
    }
494206
public List<CmsUser> searchUsers(CmsDbContext dbc, CmsUserSearchParameters searchParams

    ) throws CmsDataAccessException {

        return getUserDriver(dbc).searchUsers(dbc, searchParams);
    }
539918
public I_CmsPrincipal lookupPrincipal(CmsDbContext dbc, CmsUUID principalId) {

        try {
            CmsGroup group = getUserDriver(dbc).readGroup(dbc, principalId);
            if (group != null) {
                return group;
            }
        } catch (Exception e) {
            // ignore this exception
        }

        try {
            CmsUser user = readUser(dbc, principalId);
            if (user != null) {
                return user;
            }
        } catch (Exception e) {
            // ignore this exception
        }

        return null;
    }
1003016
public static Object createBlob(Connection conn) throws MjdbcSQLException {
        Object result = null;

        try {
            result = MappingUtils.invokeFunction(conn, "createBlob", new Class[]{}, new Object[]{});
        } catch (MjdbcException ex) {
            throw new MjdbcSQLException("createBlob is not supported by JDBC Driver", ex);
        }

        return result;
    }
1148340
private static void loadDriver(final String driver) throws FactoryException {

        // assert in private method
        assert driver != null : "The driver cannot be null";

        LOG.debug("Loading the database driver '" + driver + "'");

        // make sure the driver is available
        try {
            Class.forName(driver);
        } catch (ClassNotFoundException e) {
            final String error = "Error loading JDBC driver class: " + driver;
            LOG.warn(error, e);
            throw new FactoryException(error, e);
        }
    }
270867
Connection getConnection() throws ClassNotFoundException, SQLException{

    Class.forName(job.get(DBConfiguration.DRIVER_CLASS_PROPERTY));

    if(job.get(DBConfiguration.USERNAME_PROPERTY) == null) {
      return DriverManager.getConnection(job.get(DBConfiguration.URL_PROPERTY));
    } else {
      return DriverManager.getConnection(
          job.get(DBConfiguration.URL_PROPERTY), 
          job.get(DBConfiguration.USERNAME_PROPERTY), 
          job.get(DBConfiguration.PASSWORD_PROPERTY));
    }
  }
488815
public List<CmsPropertyDefinition> readAllPropertyDefinitions(CmsDbContext dbc) throws CmsException {

        List<CmsPropertyDefinition> result = getVfsDriver(dbc).readPropertyDefinitions(
            dbc,
            dbc.currentProject().getUuid());
        Collections.sort(result);
        return result;
    }
5367
public List<CmsHistoryProject> getAllHistoricalProjects(CmsDbContext dbc) throws CmsException {

        // user is allowed to access all existing projects for the ous he has the project_manager role
        Set<CmsOrganizationalUnit> manOus = new HashSet<CmsOrganizationalUnit>(
            getOrgUnitsForRole(dbc, CmsRole.PROJECT_MANAGER, true));

        List<CmsHistoryProject> projects = getHistoryDriver(dbc).readProjects(dbc);
        Iterator<CmsHistoryProject> itProjects = projects.iterator();
        while (itProjects.hasNext()) {
            CmsHistoryProject project = itProjects.next();
            if (project.isHidden()) {
                // project is hidden
                itProjects.remove();
                continue;
            }
            if (!project.getOuFqn().startsWith(dbc.currentUser().getOuFqn())) {
                // project is not visible from the users ou
                itProjects.remove();
                continue;
            }
            CmsOrganizationalUnit ou = readOrganizationalUnit(dbc, project.getOuFqn());
            if (manOus.contains(ou)) {
                // user is project manager for this project
                continue;
            } else if (project.getOwnerId().equals(dbc.currentUser().getId())) {
                // user is owner of the project
                continue;
            } else {
                boolean found = false;
                Iterator<CmsGroup> itGroups = getGroupsOfUser(dbc, dbc.currentUser().getName(), false).iterator();
                while (itGroups.hasNext()) {
                    CmsGroup group = itGroups.next();
                    if (project.getManagerGroupId().equals(group.getId())) {
                        found = true;
                        break;
                    }
                }
                if (found) {
                    // user is member of the manager group of the project
                    continue;
                }
            }
            itProjects.remove();
        }
        return projects;
    }
1261819
public static Connection getConnection(final String jdbcURL) throws SQLException {
        try {
            return getRealConnection(jdbcURL);
        } catch (final SQLException sqlException) {
            try {
                return (Connection) AccessController.doPrivileged(new PrivilegedExceptionAction() {
                    public Object run() throws Exception {
                        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
                        if (cl != null && cl != DriverManagerAccessor.class.getClassLoader()) {
                            final Class<?> definedClass = DriverManagerAccessorSupport.define(cl);
                            final Method method = definedClass.getDeclaredMethod("getRealConnection", String.class);
                            method.setAccessible(true);
                            return (Connection) method.invoke(null, jdbcURL);

                        } else {
                            throw sqlException;
                        }
                    }
                });
            } catch (PrivilegedActionException e) {
                throw sqlException;
            }
        }
    }
1296404
public static @NotNull Database forUrlAndCredentials(@NotNull String url, @Nullable String username, @Nullable String password) {
        return new Database(new DriverManagerConnectionProvider(url, username, password));
    }
1191633
public String getUsername() {
        final String username = basicJdbcConfiguration.getConfiguredUsername();
        if (calculatedUsername == null || StringUtils.hasText(username)) {
            calculatedUsername = username;
            if (!StringUtils.hasText(calculatedUsername) && JdbcDatabaseManager.isEmbedded(basicJdbcConfiguration.getDriverClassName())) {
                calculatedUsername = "sa";
            }
        }

        return calculatedUsername;
    }
1162064
public User resolveUser(final long userId) throws SQLException {
      metrics.userCacheTries.mark();
      User user = userCache.getIfPresent(userId);
      if(user != null) {
         metrics.userCacheHits.mark();
         return user;
      } else {
         user = selectUser(userId);
         if(user != null) {
            userCache.put(userId, user);
         }
         return user;
      }
   }