Search in sources :

Example 1 with HotClassLoader

use of org.talend.core.model.metadata.builder.database.HotClassLoader in project tdq-studio-se by Talend.

the class ManagedDriver method instanceJdbcDriver.

/**
 * create a new jdbc instance.
 *
 * @param dbType
 * @param dbVersion
 * @throws ClassNotFoundException
 * @throws InstantiationException
 * @throws IllegalAccessException
 */
private void instanceJdbcDriver(String dbType, String dbVersion) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    unregisterSQLDriver();
    JDBCDriverLoader jdbcDriverClassLoader = new JDBCDriverLoader();
    HotClassLoader hotClassLoader = jdbcDriverClassLoader.getHotClassLoader(jars.toArray(new String[jars.size()]), dbType, dbVersion);
    Class<?> classDriver = Class.forName(driverClassName, true, hotClassLoader);
    if (classDriver != null) {
        jdbcDriver = (Driver) classDriver.newInstance();
    }
}
Also used : JDBCDriverLoader(org.talend.core.model.metadata.builder.database.JDBCDriverLoader) HotClassLoader(org.talend.core.model.metadata.builder.database.HotClassLoader)

Example 2 with HotClassLoader

use of org.talend.core.model.metadata.builder.database.HotClassLoader in project tdq-studio-se by Talend.

the class ManagedDriver method registerSQLDriver.

/**
 * regist jdbc driver except Hive by HotClassLoader.
 *
 * @param dbConnection
 * @return
 * @throws ClassNotFoundException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @deprecated using registerSQLDriver(DatabaseConnection dbConn) instead of.
 */
@Deprecated
public void registerSQLDriver(String dbType, String dbVersion) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    boolean isODBC = dbType.equalsIgnoreCase(EDatabaseTypeName.GODBC.getXmlName());
    if (driverClassName != null && !dbType.equalsIgnoreCase(EDatabaseTypeName.HIVE.getXmlName()) && (isODBC || isValidatedJars())) {
        unregisterSQLDriver();
        JDBCDriverLoader jdbcDriverClassLoader = new JDBCDriverLoader();
        HotClassLoader hotClassLoader = jdbcDriverClassLoader.getHotClassLoader(jars.toArray(new String[jars.size()]), dbType, dbVersion);
        Class<?> classDriver = Class.forName(driverClassName, true, hotClassLoader);
        if (classDriver != null) {
            jdbcDriver = (Driver) classDriver.newInstance();
        }
    }
    if (jdbcDriver == null) {
        log.error("fail to regist jdbc driver in SQLExplorer");
    }
}
Also used : JDBCDriverLoader(org.talend.core.model.metadata.builder.database.JDBCDriverLoader) HotClassLoader(org.talend.core.model.metadata.builder.database.HotClassLoader)

Aggregations

HotClassLoader (org.talend.core.model.metadata.builder.database.HotClassLoader)2 JDBCDriverLoader (org.talend.core.model.metadata.builder.database.JDBCDriverLoader)2