Package org.apache.derby.iapi.services.io

Examples of org.apache.derby.iapi.services.io.FormatableProperties


                                                    null,
                                                    getContextManager());

    //we would like to use references index & table scan instead of
    //what optimizer says for the dependent table scan.
    Properties targetProperties = new FormatableProperties();
    targetProperties.put("index", "null");
    ((FromBaseTable) fromTable).setTableProperties(targetProperties);

        fromList.addFromTable(fromTable);
        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
                                                     C_NodeTypes.SELECT_NODE,
View Full Code Here


                                                    getContextManager());


    //we would like to use references index & table scan instead of
    //what optimizer says for the dependent table scan.
    Properties targetProperties = new FormatableProperties();
    targetProperties.put("index", "null");
    ((FromBaseTable) fromTable).setTableProperties(targetProperties);

        fromList.addFromTable(fromTable);

        SelectNode resultSet = (SelectNode) nodeFactory.getNode(
View Full Code Here

    String dbname = InternalDriver.getDatabaseName(url, info);

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = getAttributes(url, info);
    info = null; // ensure we don't use this reference directly again.
    boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();   
    String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);

    if (dbname.length() == 0 || (encryptDB = true && encryptpassword == null)) {

      // with no database name we can have shutdown or a database name

      // In future, if any new attribute info needs to be included in this
      // method, it just has to be added to either string or boolean or secret array
      // depending on whether it accepts string or boolean or secret(ie passwords) value.

      String[][] connStringAttributes = {
        {Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
        {Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
        {Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
        {Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
        {Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
        {Attribute.TERRITORY, MessageId.CONN_LOCALE},
        {Attribute.COLLATION, MessageId.CONN_COLLATION},
        {Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
        {Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
        {Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
        {Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
        {Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
      };

      String[][] connBooleanAttributes = {
        {Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
                {Attribute.DEREGISTER_ATTR, MessageId.CONN_DEREGISTER_AUTOLOADEDDRIVER},
        {Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
        {Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
        {Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
        };

      String[][] connStringSecretAttributes = {
        {Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
        {Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
        };

     
      DriverPropertyInfo[] optionsNoDB = new   DriverPropertyInfo[connStringAttributes.length+
                                    connBooleanAttributes.length+
                                                                connStringSecretAttributes.length];
     
      int attrIndex = 0;
      for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
                    finfo.getProperty(connStringAttributes[i][0]));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
      }

      optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
      // since database name is not stored in FormatableProperties, we
      // assign here explicitly
      optionsNoDB[0].value = dbname;

      for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
                    (finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
      }

      for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
                   Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
        optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;       
      }

      return optionsNoDB;
View Full Code Here

      return null;
    }

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = null;
       
    try {
           
            finfo = getAttributes(url, info);
            info = null; // ensure we don't use this reference directly again.

      /*
      ** A property "shutdown=true" means shut the system or database down
      */
      boolean shutdown = Boolean.valueOf(finfo.getProperty(Attribute.SHUTDOWN_ATTR)).booleanValue();
     
      if (shutdown) {
       
        // If we are shutting down the system don't attempt to create
        // a connection; but we validate users credentials if we have to.
        // In case of datbase shutdown, we ask the database authentication
        // service to authenticate the user. If it is a system shutdown,
        // then we ask the Driver to do the authentication.
        //
        if (InternalDriver.getDatabaseName(url, finfo).length() == 0) {
          //
          // We need to authenticate the user if authentication is
          // ON. Note that this is a system shutdown.
          // check that we do have a authentication service
          // it is _always_ expected.
          if (this.getAuthenticationService() == null)
            throw Util.generateCsSQLException(
                        SQLState.LOGIN_FAILED,
            MessageService.getTextMessage(MessageId.AUTH_NO_SERVICE_FOR_SYSTEM));
         
           
          if (!this.getAuthenticationService().authenticate((String) null, finfo)) {

            // not a valid user
            throw Util.generateCsSQLException(
                                  SQLState.LOGIN_FAILED, MessageService.getTextMessage(MessageId.AUTH_INVALID));
          }

          Monitor.getMonitor().shutdown();
          throw Util.generateCsSQLException(
                                         SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
        }
      }
     
      EmbedConnection conn = getNewEmbedConnection(url, finfo);

      // if this is not the correct driver a EmbedConnection
      // object is returned in the closed state.
      if (conn.isClosed()) {
        return null;
      }

      return conn;
    }
    catch (OutOfMemoryError noMemory)
    {
      EmbedConnection.memoryState.setLowMemory();
      throw EmbedConnection.NO_MEM;
    }
    finally {
      // break any link with the user's Properties set.
            if (finfo != null)
          finfo.clearDefaults();
    }
  }
View Full Code Here

  protected FormatableProperties getAttributes(String url, Properties info)
    throws SQLException {

    // We use FormatableProperties here to take advantage
    // of the clearDefaults, method.
    FormatableProperties finfo = new FormatableProperties(info);
    info = null; // ensure we don't use this reference directly again.


    StringTokenizer st = new StringTokenizer(url, ";");
    st.nextToken(); // skip the first part of the url

    while (st.hasMoreTokens()) {

      String v = st.nextToken();

      int eqPos = v.indexOf('=');
      if (eqPos == -1)
        throw Util.generateCsSQLException(
                                            SQLState.MALFORMED_URL, url);

      //if (eqPos != v.lastIndexOf('='))
      //  throw Util.malformedURL(url);

      finfo.put((v.substring(0, eqPos)).trim(),
           (v.substring(eqPos + 1)).trim()
          );
    }

    // now validate any attributes we can
View Full Code Here

    String dbname = InternalDriver.getDatabaseName(url, info);

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = getAttributes(url, info);
    info = null; // ensure we don't use this reference directly again.
    boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();   
    String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);

    if (dbname.length() == 0 || (encryptDB = true && encryptpassword == null)) {

      // with no database name we can have shutdown or a database name

      // In future, if any new attribute info needs to be included in this
      // method, it just has to be added to either string or boolean or secret array
      // depending on whether it accepts string or boolean or secret(ie passwords) value.

      String[][] connStringAttributes = {
        {Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
        {Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
        {Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
        {Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
        {Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
        {Attribute.TERRITORY, MessageId.CONN_LOCALE},
        {Attribute.COLLATION, MessageId.CONN_COLLATION},
        {Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
        {Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
        {Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
        {Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
        {Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
      };

      String[][] connBooleanAttributes = {
        {Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
        {Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
        {Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
        {Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
        };

      String[][] connStringSecretAttributes = {
        {Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
        {Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
        };

     
      DriverPropertyInfo[] optionsNoDB = new   DriverPropertyInfo[connStringAttributes.length+
                                    connBooleanAttributes.length+
                                                                connStringSecretAttributes.length];
     
      int attrIndex = 0;
      for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
                    finfo.getProperty(connStringAttributes[i][0]));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
      }

      optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
      // since database name is not stored in FormatableProperties, we
      // assign here explicitly
      optionsNoDB[0].value = dbname;

      for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
                    (finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
      }

      for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
      {
        optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
                   Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
        optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
        optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;       
      }

      return optionsNoDB;
View Full Code Here

      return null;
    }

    // convert the ;name=value attributes in the URL into
    // properties.
    FormatableProperties finfo = null;
       
    try {
           
            finfo = getAttributes(url, info);
            info = null; // ensure we don't use this reference directly again.

      /*
      ** A property "shutdown=true" means shut the system or database down
      */
      boolean shutdown = Boolean.valueOf(finfo.getProperty(Attribute.SHUTDOWN_ATTR)).booleanValue();
     
      if (shutdown) {       
        // If we are shutting down the system don't attempt to create
        // a connection; but we validate users credentials if we have to.
        // In case of datbase shutdown, we ask the database authentication
        // service to authenticate the user. If it is a system shutdown,
        // then we ask the Driver to do the authentication.
        //
        if (InternalDriver.getDatabaseName(url, finfo).length() == 0) {
          //
          // We need to authenticate the user if authentication is
          // ON. Note that this is a system shutdown.
          // check that we do have a authentication service
          // it is _always_ expected.
          if (this.getAuthenticationService() == null)
            throw Util.generateCsSQLException(
                        SQLState.LOGIN_FAILED,
            MessageService.getTextMessage(MessageId.AUTH_NO_SERVICE_FOR_SYSTEM));
         
           
          if (!this.getAuthenticationService().authenticate((String) null, finfo)) {

            // not a valid user
            throw Util.generateCsSQLException(
                                    SQLState.NET_CONNECT_AUTH_FAILED,
                                    MessageService.
                                    getTextMessage(MessageId.AUTH_INVALID));
          }

                    // DERBY-2905, allow users to provide deregister attribute to
                    // leave AutoloadedDriver registered in DriverManager, default
                    // value is true
                    if (finfo.getProperty(Attribute.DEREGISTER_ATTR) != null) {
                        boolean deregister = Boolean.valueOf(
                                finfo.getProperty(Attribute.DEREGISTER_ATTR))
                                .booleanValue();
                        AutoloadedDriver.setDeregister(deregister);
                    }

          // check for shutdown privileges
          // DERBY-3495: uncomment to enable system privileges checks
          //final String user = IdUtil.getUserNameFromURLProps(finfo);
          //checkShutdownPrivileges(user);

          Monitor.getMonitor().shutdown();

          throw Util.generateCsSQLException(
                                         SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
        }
      }
     
      EmbedConnection conn = getNewEmbedConnection(url, finfo);

      // if this is not the correct driver a EmbedConnection
      // object is returned in the closed state.
      if (conn.isClosed()) {
        return null;
      }

      return conn;
    }
    catch (OutOfMemoryError noMemory)
    {
      EmbedConnection.memoryState.setLowMemory();
      throw EmbedConnection.NO_MEM;
    }
    finally {
      // break any link with the user's Properties set.
            if (finfo != null)
          finfo.clearDefaults();
    }
  }
View Full Code Here

  protected FormatableProperties getAttributes(String url, Properties info)
    throws SQLException {

    // We use FormatableProperties here to take advantage
    // of the clearDefaults, method.
    FormatableProperties finfo = new FormatableProperties(info);
    info = null; // ensure we don't use this reference directly again.


    StringTokenizer st = new StringTokenizer(url, ";");
    st.nextToken(); // skip the first part of the url

    while (st.hasMoreTokens()) {

      String v = st.nextToken();

      int eqPos = v.indexOf('=');
      if (eqPos == -1)
        throw Util.generateCsSQLException(
                                            SQLState.MALFORMED_URL, url);

      //if (eqPos != v.lastIndexOf('='))
      //  throw Util.malformedURL(url);

      finfo.put((v.substring(0, eqPos)).trim(),
           (v.substring(eqPos + 1)).trim()
          );
    }

    // now validate any attributes we can
View Full Code Here

    this.tableName = tableName;
    this.userSuppliedOptimizerOverrides = userSuppliedOptimizerOverrides;
    this.indexName = indexName;
    this.isConstraint = isConstraint;
    this.qualifiers = qualifiers;
    this.scanProperties = new FormatableProperties();
    for (Enumeration e = scanProperties.keys(); e.hasMoreElements(); )
    {
      String key = (String)e.nextElement();
      this.scanProperties.put(key, scanProperties.get(key));
    }
View Full Code Here

    this.rowsInput = rowsInput;
    this.rowsReturned = rowsReturned;
    this.eliminateDuplicates = eliminateDuplicates;
    this.inSortedOrder = inSortedOrder;
    this.childResultSetStatistics = childResultSetStatistics;
    this.sortProperties = new FormatableProperties();
    for (Enumeration e = sortProperties.keys(); e.hasMoreElements(); )
    {
      String key = (String)e.nextElement();
      this.sortProperties.put(key, sortProperties.get(key));
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.io.FormatableProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.