Ejemplo n.º 1
0
  @Override
  public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    if (info == null) {
      info = new Properties();
    } else {
      info = PropertiesUtils.clone(info);
    }

    // construct list of driverPropertyInfo objects
    List<DriverPropertyInfo> driverProps = new LinkedList<DriverPropertyInfo>();

    parseURL(url, info);

    for (String property : JDBCURL.KNOWN_PROPERTIES.keySet()) {
      DriverPropertyInfo dpi = new DriverPropertyInfo(property, info.getProperty(property));
      if (property.equals(TeiidURL.JDBC.VDB_NAME)) {
        dpi.required = true;
      }
      driverProps.add(dpi);
    }

    // create an array of DriverPropertyInfo objects
    DriverPropertyInfo[] propInfo = new DriverPropertyInfo[driverProps.size()];

    // copy the elements from the list to the array
    return driverProps.toArray(propInfo);
  }
  /**
   * The getPropertyInfo method is intended to allow a generic GUI tool to discover what properties
   * it should prompt a human for in order to get enough information to connect to a database.
   *
   * <p>Note that depending on the values the human has supplied so far, additional values may
   * become necessary, so it may be necessary to iterate through several calls to getPropertyInfo
   *
   * @param url the Url of the database to connect to
   * @param info a proposed list of tag/value pairs that will be sent on connect open.
   * @return An array of DriverPropertyInfo objects describing possible properties. This array may
   *     be an empty array if no properties are required
   * @exception SQLException if a database-access error occurs
   * @see java.sql.Driver#getPropertyInfo
   */
  public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
    if (info == null) {
      info = new Properties();
    }

    if ((url != null) && url.startsWith(URL_PREFIX)) { // $NON-NLS-1$
      info = parseURL(url, info);
    }

    DriverPropertyInfo hostProp =
        new DriverPropertyInfo(
            HOST_PROPERTY_KEY, //$NON-NLS-1$
            info.getProperty(HOST_PROPERTY_KEY)); // $NON-NLS-1$
    hostProp.required = true;
    hostProp.description = Messages.getString("NonRegisteringDriver.3"); // $NON-NLS-1$

    DriverPropertyInfo portProp =
        new DriverPropertyInfo(
            PORT_PROPERTY_KEY, //$NON-NLS-1$
            info.getProperty(PORT_PROPERTY_KEY, "3306")); // $NON-NLS-1$ //$NON-NLS-2$
    portProp.required = false;
    portProp.description = Messages.getString("NonRegisteringDriver.7"); // $NON-NLS-1$

    DriverPropertyInfo dbProp =
        new DriverPropertyInfo(
            DBNAME_PROPERTY_KEY, //$NON-NLS-1$
            info.getProperty(DBNAME_PROPERTY_KEY)); // $NON-NLS-1$
    dbProp.required = false;
    dbProp.description = "Database name"; // $NON-NLS-1$

    DriverPropertyInfo userProp =
        new DriverPropertyInfo(
            USER_PROPERTY_KEY, //$NON-NLS-1$
            info.getProperty(USER_PROPERTY_KEY)); // $NON-NLS-1$
    userProp.required = true;
    userProp.description = Messages.getString("NonRegisteringDriver.13"); // $NON-NLS-1$

    DriverPropertyInfo passwordProp =
        new DriverPropertyInfo(
            PASSWORD_PROPERTY_KEY, //$NON-NLS-1$
            info.getProperty(PASSWORD_PROPERTY_KEY)); // $NON-NLS-1$
    passwordProp.required = true;
    passwordProp.description = Messages.getString("NonRegisteringDriver.16"); // $NON-NLS-1$

    DriverPropertyInfo[] dpi = ConnectionPropertiesImpl.exposeAsDriverPropertyInfo(info, 5);

    dpi[0] = hostProp;
    dpi[1] = portProp;
    dpi[2] = dbProp;
    dpi[3] = userProp;
    dpi[4] = passwordProp;

    return dpi;
  }
Ejemplo n.º 3
0
 public DriverPropertyInfo[] getPropertyInfo(String url, Properties properties)
     throws SQLException {
   String as[] = {"true", "false"};
   DriverPropertyInfo adriverpropertyinfo[] = new DriverPropertyInfo[6];
   DriverPropertyInfo driverpropertyinfo = new DriverPropertyInfo("user", null);
   driverpropertyinfo.value = properties.getProperty("user");
   driverpropertyinfo.required = true;
   adriverpropertyinfo[0] = driverpropertyinfo;
   driverpropertyinfo = new DriverPropertyInfo("password", null);
   driverpropertyinfo.value = properties.getProperty("password");
   driverpropertyinfo.required = true;
   adriverpropertyinfo[1] = driverpropertyinfo;
   driverpropertyinfo = new DriverPropertyInfo("get_column_name", null);
   driverpropertyinfo.value = properties.getProperty("get_column_name", "true");
   driverpropertyinfo.required = false;
   driverpropertyinfo.choices = as;
   adriverpropertyinfo[2] = driverpropertyinfo;
   driverpropertyinfo = new DriverPropertyInfo("ifexists", null);
   driverpropertyinfo.value = properties.getProperty("ifexists");
   driverpropertyinfo.required = false;
   driverpropertyinfo.choices = as;
   adriverpropertyinfo[3] = driverpropertyinfo;
   driverpropertyinfo = new DriverPropertyInfo("default_schema", null);
   driverpropertyinfo.value = properties.getProperty("default_schema");
   driverpropertyinfo.required = false;
   driverpropertyinfo.choices = as;
   adriverpropertyinfo[4] = driverpropertyinfo;
   driverpropertyinfo = new DriverPropertyInfo("shutdown", null);
   driverpropertyinfo.value = properties.getProperty("shutdown");
   driverpropertyinfo.required = false;
   driverpropertyinfo.choices = as;
   adriverpropertyinfo[5] = driverpropertyinfo;
   return adriverpropertyinfo;
 }
  /**
   * Gets information about the possible properties for this driver.
   *
   * <p>The getPropertyInfo method is intended to allow a generic GUI tool to discover what
   * properties it should prompt a human for in order to get enough information to connect to a
   * database. Note that depending on the values the human has supplied so far, additional values
   * may become necessary, so it may be necessary to iterate though several calls to
   * getPropertyInfo.
   * <!-- start release-specific documentation -->
   * <span class="ReleaseSpecificDocumentation"> <b>HSQLDB-Specific Information:</b>
   *
   * <p>HSQLDB 1.7.1 uses the values submitted in info to set the value for each DriverPropertyInfo
   * object returned. It does not use the default value that it would use for the property if the
   * value is null.
   *
   * <p></span>
   * <!-- end release-specific documentation -->
   *
   * @param url the URL of the database to which to connect
   * @param info a proposed list of tag/value pairs that will be sent on connect open
   * @return an array of DriverPropertyInfo objects describing possible properties. This array may
   *     be an empty array if no properties are required.
   */
  public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {

    String[] choices = new String[] {"true", "false"};
    DriverPropertyInfo pinfo[] = new DriverPropertyInfo[4];
    DriverPropertyInfo p;

    p = new DriverPropertyInfo("user", null);
    p.value = info.getProperty("user");
    p.required = true;
    pinfo[0] = p;
    p = new DriverPropertyInfo("password", null);
    p.value = info.getProperty("password");
    p.required = true;
    pinfo[1] = p;
    p = new DriverPropertyInfo("get_column_name", null);
    p.value = info.getProperty("get_column_name", "true");
    p.required = false;
    p.choices = choices;
    pinfo[2] = p;
    p = new DriverPropertyInfo("ifexists", null);
    p.value = info.getProperty("ifexists");
    p.required = false;
    p.choices = choices;
    pinfo[3] = p;

    return pinfo;
  }