本文整理汇总了Java中org.eclipse.datatools.connectivity.drivers.DriverInstance类的典型用法代码示例。如果您正苦于以下问题:Java DriverInstance类的具体用法?Java DriverInstance怎么用?Java DriverInstance使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DriverInstance类属于org.eclipse.datatools.connectivity.drivers包,在下文中一共展示了DriverInstance类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInvalidDriverDefinition
import org.eclipse.datatools.connectivity.drivers.DriverInstance; //导入依赖的package包/类
/**
* Checks whether the specified driver definition is invalid.
* @param driverDefnName name of a connectivity driver definition instance
* @return true if the specified driver definition exists but invalid;
* false otherwise
*/
static boolean isInvalidDriverDefinition( String driverDefnName )
{
if( driverDefnName == null || driverDefnName.length() == 0 )
return false;
DriverInstance driverInstance =
DriverManager.getInstance().getDriverInstanceByName( driverDefnName );
if( driverInstance == null )
return false;
// check if the driver instance is invalid
return ! new DriverValidator( driverInstance ).isValid( false );
}
示例2: removeInvalidDriverDefinition
import org.eclipse.datatools.connectivity.drivers.DriverInstance; //导入依赖的package包/类
/**
* Removes the specified driver definition instance, if invalid.
* This may be used by a client to clean up its obsolete driver definition,
* so a new driver instance with the current jar paths will get created
* automatically by the connectivity profile management.
* @param driverDefnName name of a connectivity driver definition instance
* @return true if the specified driver definition is found invalid and
* is successfully removed; false otherwise
*/
static boolean removeInvalidDriverDefinition( String driverDefnName )
{
if( isInvalidDriverDefinition( driverDefnName ) )
{
DriverManager driverMgr = DriverManager.getInstance();
DriverInstance driverInstance = driverMgr.getDriverInstanceByName( driverDefnName );
if( driverInstance != null )
return driverMgr.removeDriverInstance( driverInstance.getId() );
}
return false; // driver definition is valid and not removed
}
示例3: createPropertiesByVendorVersion
import org.eclipse.datatools.connectivity.drivers.DriverInstance; //导入依赖的package包/类
public static Properties createPropertiesByVendorVersion(String vendor, String version) {
Properties properties = new Properties();
for (TemplateDescriptor templateDescriptor : TemplateDescriptor.getDriverTemplateDescriptors()) {
String templateVendor = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
String templateVersion = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
if (templateVendor != null && templateVendor.equals(vendor) && templateVersion != null && templateVersion.equals(version)) {
if (!templateDescriptor.getId().endsWith(QCatalogContainer.TEMPLATE_SUFFIX))
continue;
properties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, templateVendor);
properties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, templateVersion);
// System.out.println(templateDescriptor.getId());
DriverInstance driverInstances[] = DriverManager.getInstance().getDriverInstancesByTemplate(templateDescriptor.getId());
if (driverInstances.length > 0)
properties.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, driverInstances[0].getId());
String driverClass = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
if (driverClass != null)
properties.setProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driverClass);
// platform dependent jar list
StringBuffer jarList = new StringBuffer();
try {
Bundle bundle = Platform.getBundle(templateDescriptor.getElement().getDeclaringExtension().getNamespaceIdentifier());
String paths[] = templateDescriptor.getJarList().split(";");
for (int i = 0; i < paths.length; i++) {
if (i > 0)
jarList.append(System.getProperty("path.separator"));
URL pathURL = bundle.getEntry(paths[i].trim());
jarList.append(new Path(FileLocator.toFileURL(pathURL).getFile()).toOSString());
}
} catch (IOException e) {
throw new FrameworkCoreRuntimeException(e);
}
properties.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, jarList.toString());
String driverUrl = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.URL_PROP_ID);
if (driverUrl != null)
properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID, driverUrl);
String user = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
if (user != null)
properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, user);
String password = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
if (password != null)
properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, password);
properties.setProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, Boolean.FALSE.toString());
break;
}
}
return properties;
}
示例4: createPropertiesByVendorVersion
import org.eclipse.datatools.connectivity.drivers.DriverInstance; //导入依赖的package包/类
public Properties createPropertiesByVendorVersion(String vendor, String version) {
Properties properties = new Properties();
for (TemplateDescriptor templateDescriptor : TemplateDescriptor.getDriverTemplateDescriptors()) {
String templateVendor = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID);
String templateVersion = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID);
if (templateVendor != null && templateVendor.equals(vendor) && templateVersion != null && templateVersion.equals(version)) {
if (!templateDescriptor.getId().endsWith(QCatalogContainer.TEMPLATE_SUFFIX))
continue;
properties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, templateVendor);
properties.setProperty(IJDBCDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, templateVersion);
// System.out.println(templateDescriptor.getId());
DriverInstance driverInstances[] = DriverManager.getInstance().getDriverInstancesByTemplate(templateDescriptor.getId());
if (driverInstances.length > 0)
properties.setProperty(ConnectionProfileConstants.PROP_DRIVER_DEFINITION_ID, driverInstances[0].getId());
String driverClass = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID);
if (driverClass != null)
properties.setProperty(IJDBCDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, driverClass);
// platform dependent jar list
StringBuffer jarList = new StringBuffer();
try {
Bundle bundle = Platform.getBundle(templateDescriptor.getElement().getDeclaringExtension().getNamespaceIdentifier());
String paths[] = templateDescriptor.getJarList().split(";");
for (int i = 0; i < paths.length; i++) {
if (i > 0)
jarList.append(System.getProperty("path.separator"));
URL pathURL = bundle.getEntry(paths[i].trim());
jarList.append(new Path(FileLocator.toFileURL(pathURL).getFile()).toOSString());
}
} catch (IOException e) {
throw new FrameworkCoreRuntimeException(e);
}
properties.setProperty(IDriverMgmtConstants.PROP_DEFN_JARLIST, jarList.toString());
String driverUrl = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.URL_PROP_ID);
if (driverUrl != null)
properties.setProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID, driverUrl);
String user = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
if (user != null)
properties.setProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID, user);
String password = templateDescriptor.getPropertyValueFromId(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
if (password != null)
properties.setProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID, password);
properties.setProperty(IJDBCConnectionProfileConstants.SAVE_PASSWORD_PROP_ID, Boolean.FALSE.toString());
break;
}
}
return properties;
}
示例5: getDriverDefinition
import org.eclipse.datatools.connectivity.drivers.DriverInstance; //导入依赖的package包/类
@Override
protected DriverInstance getDriverDefinition() throws Exception {
// TODO Auto-generated method stub
return super.getDriverDefinition();
}