Load a class, e.g. the JDBC driver.

@param driver
The class name.
11391
private void loadDriver(String driver) throws IOException {
        if (driver != null) {
            try {
                Class.forName(driver);
            } catch (ClassNotFoundException e) {
                throw new IOException(driver + " cannot be loaded, skipping scan of schema.", e);
            }
        }
    }
183795
public final void initApplicationClassLoader(ClassLoader loader)
    {
        if (loader == null)
            throw new IllegalArgumentException("loader is null");
        if (!Kit.testIfCanLoadRhinoClasses(loader))
            throw new IllegalArgumentException(
                "Loader can not resolve Rhino classes");

        if (this.applicationClassLoader != null)
            throw new IllegalStateException(
                "applicationClassLoader can only be set once");
        checkNotSealed();

        this.applicationClassLoader = loader;
    }
1128599
protected final void load()throws Exception
	{
		synchronized (this) {
			Set<Class<?>> classes=classProvider.getLoadedClasses();
			initScriptClasses(classes);
			onScriptLoaded(classes);
		}
	}
858361
private static void loadDriver(String classname) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
		if(!driversLoaded.containsKey(classname)) {
			Object O = Class.forName(classname).newInstance();
			driversLoaded.putIfAbsent(classname, O);
		}
	}
962915
static void initializeDatabaseDriver(String databaseType) {
    String driverClass = System.getProperty(JDBC_DRIVER_CLASS_KEY_PREFIX + databaseType);
    if (driverClass != null) {
      Log.debug("Loading " + driverClass + " to initialize database of type " + databaseType);
      try {
        Class.forName(driverClass);
      } catch (ClassNotFoundException e) {
        throw new RuntimeException("Connection to '" + databaseType + "' database is not possible due to missing JDBC driver. " +
                "User specified driver class: " + driverClass, e);
      }
      return;
    }
    // use built-in defaults
    switch (databaseType) {
      case HIVE_DB_TYPE:
        try {
          Class.forName(HIVE_JDBC_DRIVER_CLASS);
        } catch (ClassNotFoundException e) {
          throw new RuntimeException("Connection to HIVE database is not possible due to missing JDBC driver.", e);
        }
        break;
      case NETEZZA_DB_TYPE:
        try {
          Class.forName(NETEZZA_JDBC_DRIVER_CLASS);
        } catch (ClassNotFoundException e) {
          throw new RuntimeException("Connection to Netezza database is not possible due to missing JDBC driver.", e);
        }
        break;
      default:
        //nothing to do
    }
  }
76861
@Nonnull
  public Class <?> loadClass (final String sClassName) throws ClassNotFoundException
  {
    if (m_aBestCandidate != null)
    {
      try
      {
        return m_aBestCandidate.loadClass (sClassName);
      }
      catch (final Throwable t)
      {
        m_aBestCandidate = null;
      }
    }

    Throwable aThrowable = null;
    Class <?> ret = null;
    IClassLoadHelper aLoadHelper = null;

    final Iterator <IClassLoadHelper> iter = m_aLoadHelpers.iterator ();
    while (iter.hasNext ())
    {
      aLoadHelper = iter.next ();
      try
      {
        ret = aLoadHelper.loadClass (sClassName);
        break;
      }
      catch (final Throwable t)
      {
        aThrowable = t;
      }
    }

    if (ret == null)
    {
      if (aThrowable instanceof ClassNotFoundException)
        throw (ClassNotFoundException) aThrowable;
      throw new ClassNotFoundException ("Unable to load class " + sClassName + " by any known loaders.", aThrowable);
    }

    // Remember
    m_aBestCandidate = aLoadHelper;
    return ret;
  }
283552
public static void loadDriver(String driverClassName) throws ClassNotFoundException {
        // let's try the thread context class loader first
        // let's try to use the system class loader
        try {
            Class.forName(driverClassName);
        }
        catch (ClassNotFoundException e) {
            try {
                Thread.currentThread().getContextClassLoader().loadClass(driverClassName);
            }
            catch (ClassNotFoundException e2) {
                // now let's try the classloader which loaded us
                try {
                    Sql.class.getClassLoader().loadClass(driverClassName);
                }
                catch (ClassNotFoundException e3) {
                    throw e;
                }
            }
        }
    }
818178
@SuppressWarnings("unchecked")
	public static <T> Class<T> loadClass(String className, boolean isInitialized) {
		return (Class<T>) ClassLoaderUtil.loadClass(className, isInitialized);
	}
140714
@SuppressWarnings("unchecked")
    public static <T> Class<T> loadClass(String className) throws ClassNotFoundException {
        return (Class<T>) getClassLoader().loadClass(className);
    }
1310651
public static Class<?> loadClass(String classname) {
        Class<?> c = null;

        // First try a simple Class.forName()
        try { c = Class.forName(classname); } catch (ClassNotFoundException e) { }
        // Didn't work?  Try using this class's classloader.
        if (c == null) {
            try { c = ReflectionUtils.class.getClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }
        // Still didn't work?  Try the thread's context classloader.
        if (c == null) {
            try { c = Thread.currentThread().getContextClassLoader().loadClass(classname); } catch (ClassNotFoundException e) { }
        }

        return c;
    }
695198
public static Driver loadDriver(final File jar) {
        try {
            return loadDriver(jar.toURI().toURL());
        } catch (java.net.MalformedURLException e) {
            throw new RuntimeException(e);
        } // end of catch
    }
1188761
static Object newInstance (ClassLoader classLoader, String className)
        throws ClassNotFoundException, IllegalAccessException,
            InstantiationException
    {
        Class driverClass;
        if (classLoader == null) {
            driverClass = Class.forName(className);
        } else {
            driverClass = classLoader.loadClass(className);
        }
        return driverClass.newInstance();
    }
263173
static Class<?> loadClass(ClassLoader cl, String classTypeName) throws InvocationException {
        try {
            return cl.loadClass(classTypeName);
        } catch (ClassNotFoundException e) {
            throw new InvocationException(e, "Unable to load class {0} with class loader {1}", classTypeName, cl);
        }
    }
127798
@Override
    public Class<?> loadClass(String classname) throws ClassNotFoundException {
        return getClass().getClassLoader().loadClass(classname);
    }
25324
void loadClient(String persistenceUnit, Client client)
    {
        if (!clientMap.containsKey(persistenceUnit) && client != null)
        {
            clientMap.put(persistenceUnit, client);
        }
    }
152723
public void setDriverClassName(String driver)
    {
        try
        {
            this.driver = (Driver) Class.forName(driver).newInstance();
        }
        catch (Exception e)
        {
            throw new RuntimeException("Unable to load driver: " + driver, e);
        }
    }
792855
protected void load()
    {
        Logger bootLogger = LoggerFactory.getBootLogger();

        // first we check whether the system property
        //   org.apache.ojb.broker.util.logging.Logger
        // is set (or its alias LoggerClass which is deprecated)
        ClassLoader contextLoader   = ClassHelper.getClassLoader();
        String      loggerClassName;

        _loggerClass      = null;
        properties        = new Properties();
        loggerClassName   = getLoggerClass(System.getProperties());
        _loggerConfigFile = getLoggerConfigFile(System.getProperties());

        InputStream ojbLogPropFile;
        if (loggerClassName == null)
        {
            // now we're trying to load the OJB-logging.properties file
            String ojbLogPropFilePath = System.getProperty(OJB_LOGGING_PROPERTIES_FILE, OJB_LOGGING_PROPERTIES_FILE);
            try
            {
                URL ojbLoggingURL = ClassHelper.getResource(ojbLogPropFilePath);
                if (ojbLoggingURL == null)
                {
                    ojbLoggingURL = (new File(ojbLogPropFilePath)).toURL();
                }
                ojbLogPropFile = ojbLoggingURL.openStream();
                try
                {
                    bootLogger.info("Found logging properties file: " + ojbLogPropFilePath);
                    properties.load(ojbLogPropFile);
                    _loggerConfigFile = getLoggerConfigFile(properties);
                    loggerClassName = getLoggerClass(properties);
                }
                finally
                {
                    ojbLogPropFile.close();
                }
            }
            catch (Exception ex)
            {
                if(loggerClassName == null)
                {
                    bootLogger.warn("Can't read logging properties file using path '" + ojbLogPropFilePath
                            + "', message is: " + SystemUtils.LINE_SEPARATOR + ex.getMessage()
                            + SystemUtils.LINE_SEPARATOR + "Will try to load logging properties from OJB.properties file");
                }
                else
                {
                    bootLogger.info("Problems while closing resources for path '" + ojbLogPropFilePath
                            + "', message is: " + SystemUtils.LINE_SEPARATOR + ex.getMessage(), ex);
                }
            }
        }
        if (loggerClassName == null)
        {
            // deprecated: load the OJB.properties file
            // this is not good because we have all OJB properties in this config
            String ojbPropFile = System.getProperty("OJB.properties", "OJB.properties");

            try
            {
                ojbLogPropFile = contextLoader.getResourceAsStream(ojbPropFile);
                if (ojbLogPropFile != null)
                {
                    try
                    {
                        properties.load(ojbLogPropFile);
                        loggerClassName   = getLoggerClass(properties);
                        _loggerConfigFile = getLoggerConfigFile(properties);
                        if (loggerClassName != null)
                        {
                            // deprecation warning for after 1.0
                            bootLogger.warn("Please use a separate '"+OJB_LOGGING_PROPERTIES_FILE+"' file to specify your logging settings");
                        }
                    }
                    finally
                    {
                        ojbLogPropFile.close();
                    }
                }
            }
            catch (Exception ex)
            {}
        }
        if (loggerClassName != null)
        {
            try
            {
                _loggerClass = ClassHelper.getClass(loggerClassName);
                bootLogger.info("Logging: Found logger class '" + loggerClassName);
            }
            catch (ClassNotFoundException ex)
            {
                _loggerClass = PoorMansLoggerImpl.class;
                bootLogger.warn("Could not load logger class "+loggerClassName+", defaulting to "+_loggerClass.getName(), ex);
            }
        }
        else
        {
            // still no logger configured - lets check whether commons-logging is configured
            if ((System.getProperty(PROPERTY_COMMONS_LOGGING_LOG) != null) ||
                (System.getProperty(PROPERTY_COMMONS_LOGGING_LOGFACTORY) != null))
            {
                // yep, so use commons-logging
                _loggerClass = CommonsLoggerImpl.class;
                bootLogger.info("Logging: Found commons logging properties, use " + _loggerClass);
            }
            else
            {
                // but perhaps there is a log4j.properties file ?
                try
                {
                    ojbLogPropFile = contextLoader.getResourceAsStream("log4j.properties");
                    if (ojbLogPropFile != null)
                    {
                        // yep, so use log4j
                        _loggerClass      = Log4jLoggerImpl.class;
                        _loggerConfigFile = "log4j.properties";
                        bootLogger.info("Logging: Found 'log4j.properties' file, use " + _loggerClass);
                        ojbLogPropFile.close();
                    }
                }
                catch (Exception ex)
                {}
                if (_loggerClass == null)
                {
                    // or a commons-logging.properties file ?
                    try
                    {
                        ojbLogPropFile = contextLoader.getResourceAsStream("commons-logging.properties");
                        if (ojbLogPropFile != null)
                        {
                            // yep, so use commons-logging
                            _loggerClass      = CommonsLoggerImpl.class;
                            _loggerConfigFile = "commons-logging.properties";
                            bootLogger.info("Logging: Found 'commons-logging.properties' file, use " + _loggerClass);
                            ojbLogPropFile.close();
                        }
                    }
                    catch (Exception ex)
                    {}
                    if (_loggerClass == null)
                    {
                        // no, so default to poor man's logging
                        bootLogger.info("** Can't find logging configuration file, use default logger **");
                        _loggerClass = PoorMansLoggerImpl.class;
                    }
                }
            }
        }
    }