コード例 #1
0
  /**
   * Get dburl which content are replaced by parameter value.(note: for mssql, this method result is
   * wrong, so i deprecated this method)
   *
   * @param dbType
   * @param host
   * @param port
   * @param dbName
   * @param dataSource
   * @param paramString TODO
   * @return
   * @deprecated use {@link #getDBUrl(String dbType, String Version, String host, String username,
   *     String password, String port, String dbName, String dataSource, String paramString)}
   */
  @Deprecated
  public String getDBUrl(
      String dbType,
      String host,
      String port,
      String dbName,
      String dataSource,
      String paramString) {
    String propUrlValue = PROP.getProperty(dbType);
    SupportDBUrlType defaultUrlType = supportDBUrlMap.get(dbType);
    // defaultUrlType = defaultUrlType == null ? SupportDBUrlType.ODBCDEFAULTURL : defaultUrlType;
    defaultUrlType = defaultUrlType == null ? SupportDBUrlType.MYSQLDEFAULTURL : defaultUrlType;
    if (propUrlValue == null) {
      return PluginConstant.EMPTY_STRING;
    }

    String argHost = (host == null) ? PluginConstant.EMPTY_STRING : host;
    String argPort = (port == null) ? PluginConstant.EMPTY_STRING : port;
    String argDBName = (dbName == null) ? PluginConstant.EMPTY_STRING : dbName;
    String argDataSource = (dataSource == null) ? PluginConstant.EMPTY_STRING : dataSource;
    Object[] argsUrl = {argHost, argPort, argDBName, argDataSource};
    if (paramString.equals(PluginConstant.EMPTY_STRING)) {
      return MessageFormat.format(propUrlValue, argsUrl);
    } else {
      return MessageFormat.format(propUrlValue, argsUrl)
          + defaultUrlType.getParamSeprator()
          + paramString;
    }
  }
コード例 #2
0
 public void changeAllDBNmae(String dbName) {
   Iterator<String> it = supportDBUrlMap.keySet().iterator();
   while (it.hasNext()) {
     SupportDBUrlType dbType = supportDBUrlMap.get(it.next());
     if (dbType.getDBName() != null) {
       dbType.setDBName(dbName);
     }
   }
 }
コード例 #3
0
 /**
  * Get the dburl via the dbType, and the dburl content come from the default value of
  * SupportDBUrlType.
  *
  * @param dbType
  * @return
  */
 public String getDefaultDBUrl(String dbType) {
   String propUrlValue = PROP.getProperty(dbType);
   SupportDBUrlType defaultUrlType = supportDBUrlMap.get(dbType);
   // defaultUrlType = defaultUrlType == null ? SupportDBUrlType.ODBCDEFAULTURL : defaultUrlType;
   defaultUrlType = defaultUrlType == null ? SupportDBUrlType.MYSQLDEFAULTURL : defaultUrlType;
   if (propUrlValue == null) {
     return PluginConstant.EMPTY_STRING;
   }
   Object[] args = {
     defaultUrlType.getHostName(),
     defaultUrlType.getPort(),
     defaultUrlType.getDBName(),
     defaultUrlType.getDataSource()
   };
   return MessageFormat.format(propUrlValue, args);
 }
コード例 #4
0
 /**
  * get dburl which content are replaced by parameter value.
  *
  * @param dbType
  * @param dbVersion
  * @param host
  * @param username
  * @param password
  * @param port
  * @param dbName
  * @param dataSource
  * @param paramString
  * @return
  */
 public String getDBUrl(
     String dbType,
     String dbVersion,
     String host,
     String username,
     String password,
     String port,
     String dbName,
     String dataSource,
     String paramString) {
   if (SupportDBUrlType.isMssql(dbType)) {
     // TDQ-12794: for mssql, because of some changes, we need to do like this
     String versionStr = changeMSSQLVersion(dbVersion);
     EDatabaseVersion4Drivers version =
         EDatabaseVersion4Drivers.indexOfByVersionDisplay(versionStr);
     if (version != null) {
       versionStr = version.getVersionValue();
     }
     return DatabaseConnStrUtil.getURLString(
         dbType,
         versionStr,
         host,
         username,
         password,
         port,
         dbName,
         StringUtils.EMPTY,
         StringUtils.EMPTY,
         StringUtils.EMPTY,
         paramString);
   } else {
     return getDBUrl(dbType, host, port, dbName, StringUtils.EMPTY, paramString);
   }
 }
コード例 #5
0
  public String[] getDBLanguages() {
    Set<String> tempList = new HashSet<String>();

    for (SupportDBUrlType type : SupportDBUrlType.values()) {
      String language = type.getLanguage();

      if (supportDBUrlMap.containsKey(type.getDBKey())) {
        tempList.add(language);
      }
    }

    String[] dbLanguages = tempList.toArray(new String[tempList.size()]);
    Arrays.sort(dbLanguages);

    return dbLanguages;
  }
コード例 #6
0
 public String getDBUrl(SupportDBUrlType dbType) {
   return getDBUrl(
       dbType.getDBKey(),
       dbType.getHostName(),
       dbType.getPort(),
       dbType.getDBName(),
       dbType.getDataSource(),
       dbType.getParamSeprator() != null
           ? PluginConstant.DEFAULT_PARAMETERS
           : PluginConstant.EMPTY_STRING);
 }