当前位置: 首页>>代码示例>>Java>>正文


Java PreferenceInitializer.getJDBCDriverPath方法代码示例

本文整理汇总了Java中org.insightech.er.preference.PreferenceInitializer.getJDBCDriverPath方法的典型用法代码示例。如果您正苦于以下问题:Java PreferenceInitializer.getJDBCDriverPath方法的具体用法?Java PreferenceInitializer.getJDBCDriverPath怎么用?Java PreferenceInitializer.getJDBCDriverPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.insightech.er.preference.PreferenceInitializer的用法示例。


在下文中一共展示了PreferenceInitializer.getJDBCDriverPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDriverClass

import org.insightech.er.preference.PreferenceInitializer; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public Class<Driver> getDriverClass(final String driverClassName) {
    String path = null;
    Class clazz = null;

    try {
        if (driverClassName.equals("sun.jdbc.odbc.JdbcOdbcDriver")) {
            return (Class<Driver>) Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

        } else {
            path = PreferenceInitializer.getJDBCDriverPath(getId(), driverClassName);

            // Cache the class loader to map.
            // Because if I use the another loader with the driver using
            // native library(.dll)
            // next error occur.
            //
            // java.lang.UnsatisfiedLinkError: Native Library xxx.dll
            // already loaded in another classloader
            //
            ClassLoader loader = loaderMap.get(path);
            if (loader == null) {
                loader = getClassLoader(path);
                loaderMap.put(path, loader);
            }

            clazz = loader.loadClass(driverClassName);
        }

    } catch (final Exception e) {
        final JDBCPathDialog dialog = new JDBCPathDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), getId(), driverClassName, path, new ArrayList<JDBCDriverSetting>(), false);

        if (dialog.open() == IDialogConstants.OK_ID) {
            final JDBCDriverSetting newDriverSetting = new JDBCDriverSetting(getId(), dialog.getDriverClassName(), dialog.getPath());

            final List<JDBCDriverSetting> driverSettingList = PreferenceInitializer.getJDBCDriverSettingList();

            if (driverSettingList.contains(newDriverSetting)) {
                driverSettingList.remove(newDriverSetting);
            }
            driverSettingList.add(newDriverSetting);

            PreferenceInitializer.saveJDBCDriverSettingList(driverSettingList);

            clazz = getDriverClass(dialog.getDriverClassName());
        }
    }

    return clazz;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:52,代码来源:DBManagerBase.java

示例2: getDriverClass

import org.insightech.er.preference.PreferenceInitializer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public Class<Driver> getDriverClass(String driverClassName) {
	String path = null;
	Class clazz = null;

	try {
		if (driverClassName.equals("sun.jdbc.odbc.JdbcOdbcDriver")) {
			return (Class<Driver>) Class
					.forName("sun.jdbc.odbc.JdbcOdbcDriver");

		} else {
			path = PreferenceInitializer.getJDBCDriverPath(this.getId(),
					driverClassName);

			// Cache the class loader to map.
			// Because if I use the another loader with the driver using
			// native library(.dll)
			// next error occur.
			//
			// java.lang.UnsatisfiedLinkError: Native Library xxx.dll
			// already loaded in another classloader
			//
			ClassLoader loader = this.loaderMap.get(path);
			if (loader == null) {
				loader = this.getClassLoader(path);
				this.loaderMap.put(path, loader);
			}

			clazz = loader.loadClass(driverClassName);
		}

	} catch (Exception e) {
		JDBCPathDialog dialog = new JDBCPathDialog(PlatformUI
				.getWorkbench().getActiveWorkbenchWindow().getShell(),
				this.getId(), driverClassName, path,
				new ArrayList<JDBCDriverSetting>(), false);

		if (dialog.open() == IDialogConstants.OK_ID) {
			JDBCDriverSetting newDriverSetting = new JDBCDriverSetting(
					this.getId(), dialog.getDriverClassName(),
					dialog.getPath());

			List<JDBCDriverSetting> driverSettingList = PreferenceInitializer
					.getJDBCDriverSettingList();

			if (driverSettingList.contains(newDriverSetting)) {
				driverSettingList.remove(newDriverSetting);
			}
			driverSettingList.add(newDriverSetting);

			PreferenceInitializer
					.saveJDBCDriverSettingList(driverSettingList);

			clazz = this.getDriverClass(dialog.getDriverClassName());
		}
	}

	return clazz;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:60,代码来源:DBManagerBase.java


注:本文中的org.insightech.er.preference.PreferenceInitializer.getJDBCDriverPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。