當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。