Exemple #1
0
  /** Sends Emails to Customers who have not submitted their Bears */
  public static void BearEmailSendMessage(String msgsubject, String msgText, String msgTo) {
    try {
      BearFrom = props.getProperty("BEARFROM");
      // To = props.getProperty("TO");
      SMTPHost = props.getProperty("SMTPHOST");
      Properties mailprops = new Properties();
      mailprops.put("mail.smtp.host", SMTPHost);

      // create some properties and get the default Session
      Session session = Session.getDefaultInstance(mailprops, null);

      // create a message
      Message msg = new MimeMessage(session);

      // set the from
      InternetAddress from = new InternetAddress(BearFrom);
      msg.setFrom(from);
      InternetAddress[] address = InternetAddress.parse(msgTo);
      msg.setRecipients(Message.RecipientType.TO, address);
      msg.setSubject(msgsubject);
      msg.setContent(msgText, "text/plain");
      Transport.send(msg);
    } // end try
    catch (MessagingException mex) {
      USFEnv.getLog().writeCrit("Message not sent", null, null);
    } catch (Exception ex) {
      USFEnv.getLog().writeCrit("Message not sent", null, null);
    }
  } // end BearEmailSendMessage
Exemple #2
0
 /**
  * Parses connection options.
  *
  * @param options options
  * @return connection properties
  */
 private static Properties connProps(final HashMap<String, String> options) {
   final Properties props = new Properties();
   for (final Entry<String, String> entry : options.entrySet()) {
     props.setProperty(entry.getKey(), entry.getValue());
   }
   return props;
 }
Exemple #3
0
  /**
   * Test batched prepared statement concurrency. Batch prepares must not disappear between the
   * moment when they were created and when they are executed.
   */
  public void testConcurrentBatching() throws Exception {
    // Create a connection with a batch size of 1. This should cause prepares and actual batch
    // execution to become
    // interspersed (if correct synchronization is not in place) and greatly increase the chance of
    // prepares
    // being rolled back before getting executed.
    Properties props = new Properties();
    props.setProperty(Messages.get(net.sourceforge.jtds.jdbc.Driver.BATCHSIZE), "1");
    props.setProperty(
        Messages.get(net.sourceforge.jtds.jdbc.Driver.PREPARESQL),
        String.valueOf(TdsCore.TEMPORARY_STORED_PROCEDURES));
    Connection con = getConnection(props);

    try {
      Statement stmt = con.createStatement();
      stmt.execute(
          "create table #testConcurrentBatch (v1 int, v2 int, v3 int, v4 int, v5 int, v6 int)");
      stmt.close();

      Vector exceptions = new Vector();
      con.setAutoCommit(false);

      Thread t1 = new ConcurrentBatchingHelper(con, exceptions);
      Thread t2 = new ConcurrentBatchingHelper(con, exceptions);
      t1.start();
      t2.start();
      t1.join();
      t2.join();

      assertEquals(0, exceptions.size());
    } finally {
      con.close();
    }
  }
  public Connection getConnection() throws SQLException {
    synchronized (pool) {
      if (!pool.isEmpty()) {
        int last = pool.size() - 1;
        Connection pooled = (Connection) pool.remove(last);

        boolean conn_ok = true;
        String test_table = prop.getProperty("test_table");
        if (test_table != null) {
          Statement stmt = null;
          try {
            stmt = pooled.createStatement();
            stmt.executeQuery("select * from " + prop.getProperty("test_table"));
          } catch (SQLException ex) {
            conn_ok = false; // 连接不可用
          } finally {
            if (stmt != null) {
              stmt.close();
            }
          }
        }
        if (conn_ok == true) {
          return pooled;
        } else {
          pooled.close();
        }
      }
    }
    Connection conn =
        DriverManager.getConnection(
            prop.getProperty("url"), prop.getProperty("username"), prop.getProperty("password"));
    return conn;
  }
  @Override
  public void init(Context context, Properties initProps) {
    initProps = decryptPwd(initProps);
    Object o = initProps.get(CONVERT_TYPE);
    if (o != null) convertType = Boolean.parseBoolean(o.toString());

    factory = createConnectionFactory(context, initProps);

    String bsz = initProps.getProperty("batchSize");
    if (bsz != null) {
      bsz = context.replaceTokens(bsz);
      try {
        batchSize = Integer.parseInt(bsz);
        if (batchSize == -1) batchSize = Integer.MIN_VALUE;
      } catch (NumberFormatException e) {
        LOG.warn("Invalid batch size: " + bsz);
      }
    }

    for (Map<String, String> map : context.getAllEntityFields()) {
      String n = map.get(DataImporter.COLUMN);
      String t = map.get(DataImporter.TYPE);
      if ("sint".equals(t) || "integer".equals(t)) fieldNameVsType.put(n, Types.INTEGER);
      else if ("slong".equals(t) || "long".equals(t)) fieldNameVsType.put(n, Types.BIGINT);
      else if ("float".equals(t) || "sfloat".equals(t)) fieldNameVsType.put(n, Types.FLOAT);
      else if ("double".equals(t) || "sdouble".equals(t)) fieldNameVsType.put(n, Types.DOUBLE);
      else if ("date".equals(t)) fieldNameVsType.put(n, Types.DATE);
      else if ("boolean".equals(t)) fieldNameVsType.put(n, Types.BOOLEAN);
      else if ("binary".equals(t)) fieldNameVsType.put(n, Types.BLOB);
      else fieldNameVsType.put(n, Types.VARCHAR);
    }
  }
  private LogisticRegressionModel instantiateSparkModel() {
    Configuration conf = new Configuration();
    conf.set("fs.defaultFS", topologyConfig.getProperty("hdfs.url"));

    double[] sparkModelInfo = null;

    try {
      sparkModelInfo =
          getSparkModelInfoFromHDFS(
              new Path(topologyConfig.getProperty("hdfs.url") + "/tmp/sparkML_weights"), conf);
    } catch (Exception e) {
      LOG.error("Couldn't instantiate Spark model in prediction bolt: " + e.getMessage());
      e.printStackTrace();

      throw new RuntimeException(e);
    }

    // all numbers besides the last value are the weights
    double[] weights = Arrays.copyOfRange(sparkModelInfo, 0, sparkModelInfo.length - 1);

    // the last number in the array is the intercept
    double intercept = sparkModelInfo[sparkModelInfo.length - 1];

    org.apache.spark.mllib.linalg.Vector weightsV = (Vectors.dense(weights));
    return new LogisticRegressionModel(weightsV, intercept);
  }
Exemple #7
0
  public void t1estDataSource() {
    Connection con = null;
    Statement st = null;
    try {
      P6TestUtil.unloadDrivers();

      // try to do a simple test using the datasourcey stuff
      Properties props = P6TestUtil.loadProperties("P6Test.properties");
      String user = props.getProperty("user");
      String password = props.getProperty("password");
      String url = props.getProperty("url");

      P6DriverManagerDataSource ds = new P6DriverManagerDataSource();

      ds.setUrl(url);

      con = ds.getConnection(user, password);
      st = con.createStatement();
      st.execute("create table foo (col1 varchar2(255))");
      st.execute("insert into table foo values ('1')");

      ResultSet rs = st.executeQuery("select count(*) from foo");
      // assertTrue(rs.

    } catch (Exception e) {
      e.printStackTrace(System.out);
      fail("unexpected exception: " + e);
    } finally {

    }
  }
 public static void init() throws Exception {
   Properties props = new Properties();
   int pid = OSProcess.getId();
   String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
   /** * Return file as string and then modify the string accordingly ** */
   String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"));
   file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
   String modified_file_str = modifyFile(file_as_str);
   FileOutputStream fos = new FileOutputStream(path);
   BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
   wr.write(modified_file_str);
   wr.flush();
   wr.close();
   props.setProperty("cache-xml-file", path);
   //    String tableName = "";
   //		  props.setProperty("mcast-port", "10339");
   try {
     //			   ds = DistributedSystem.connect(props);
     ds = (new ExceptionsDUnitTest("temp")).getSystem(props);
     cache = CacheFactory.create(ds);
   } catch (Exception e) {
     e.printStackTrace(System.err);
     throw new Exception("" + e);
   }
 }
 public void initParam(String paramFile) throws Exception {
   // 使用Properties类来加载属性文件
   Properties props = new Properties();
   props.load(new FileInputStream(paramFile));
   driver = props.getProperty("driver");
   url = props.getProperty("url");
   user = props.getProperty("user");
   pass = props.getProperty("pass");
 }
 //	----------------------------------------------------------------------------------------------------------------
 //       Method:    getConnection
 //       Inputs:	database URL, username, password
 //      Outputs:	connection to DB
 //  Description:    Connects to MySql database
 //	----------------------------------------------------------------------------------------------------------------
 private static Connection getConnection(String dbURL, String user, String password)
     throws SQLException, ClassNotFoundException {
   Class.forName("com.mysql.jdbc.Driver"); // Setup for the MySql JDBC Driver
   Properties props = new Properties(); // Build the properties
   props.put("user", user);
   props.put("password", password);
   props.put("autoReconnect", "true"); // Enabled auto-reconnection
   return DriverManager.getConnection(dbURL, props); // Return the connection to the database
 }
 public static Properties loadProperties() {
   Properties p = new Properties();
   try {
     p.load(new FileInputStream(CONF_SPATIAL_PROPERTIES_FILE));
   } catch (IOException e) {
     p = null;
     logger.warn(e.getMessage(), e);
   }
   return p;
 }
  private static void truncateSeleniumTables(List<String> tables) {
    Properties props = getSeleniumProperties();

    clearDatabaseAndSkipBaseData(
        tables,
        props.getProperty(DB_URL_KEY),
        props.getProperty(DB_USER_KEY),
        props.getProperty(DB_PASS_KEY),
        props.getProperty(DB_DRIVER_CLASS_KEY));
  }
 private static Properties getSeleniumProperties() {
   Properties props = new Properties();
   try {
     props.load(
         DatabaseTestHelper.class.getResourceAsStream("/env-properties/bod-selenium.properties"));
     return props;
   } catch (IOException e) {
     throw new AssertionError(e);
   }
 }
Exemple #14
0
  Competition getDataFromDatabase(String arg, Properties properties) {
    Competition competition = new Competition();

    String getAthleteDataQuery =
        "SELECT athletes.name, athletes.dob, athletes.country_code, "
            + "results.race_100m, results.long_jump, results.shot_put, results.high_jump, results.race_400m, "
            + "results.hurdles_110m, results.discus_throw, results.pole_vault, results.javelin_throw, results.race_1500m "
            + "FROM athletes, results, competitions "
            + "WHERE athletes.id = results.athlete_id "
            + "AND results.competition_id = competitions.id "
            + "AND (competitions.id = ? OR competitions.name = ?)";

    Connection conn = null;

    try {
      String url = properties.getProperty("db.url");
      String username = properties.getProperty("db.username");
      String password = properties.getProperty("db.password");

      conn = DriverManager.getConnection(url, username, password);
      PreparedStatement athleteDataQuery = conn.prepareStatement(getAthleteDataQuery);
      athleteDataQuery.setString(1, arg);
      athleteDataQuery.setString(2, arg);
      ResultSet resultSet = athleteDataQuery.executeQuery();

      while (resultSet.next()) {
        Athlete athlete = parseAthlete(resultSet);
        if (athlete == null) {
          System.out.println(Error.ERROR_DB_ATHLETE_PARSING_FAILED.getErrorText());
          continue;
        }

        DecathlonEvents decathlonEvents = parseDecathlonEvents(resultSet);
        if (decathlonEvents == null) {
          System.out.println(Error.ERROR_DB_ATHLETE_RESULTS_PARSING_FAILED.getErrorText());
          continue;
        }
        athlete.setDecathlonEvent(decathlonEvents);

        competition.addAthlete(athlete);
      }
    } catch (SQLException e) {
      System.out.println(Error.ERROR_DB_CONNECTION.getErrorText());
    } finally {
      if (conn != null)
        try {
          conn.close();
        } catch (SQLException e) {
          System.out.println(Error.ERROR_DB_CLOSE.getErrorText());
        }
    }
    return competition;
  }
Exemple #15
0
 public void koneksiDatabase() {
   try {
     String url = "jdbc:mysql://localhost:3306/payroll_db";
     Properties prop = new Properties();
     prop.put("user", "root");
     prop.put("password", "admin");
     konek = DriverManager.getConnection(url, prop);
     status_Proses(true, "Sukses!!!Berhasil Terhubung dengan Database...", 20);
   } catch (SQLException se) {
     status_Proses(false, "Gagal!!!Tidak terhubung \nKarena : " + se, 20);
   }
 }
Exemple #16
0
  /** 利用属性文件中的信息连接数据库 * */
  public static Connection getConnection() throws SQLException, IOException {
    Properties props = new Properties();
    String fileName = "QueryDB.properties";
    FileInputStream in = new FileInputStream(fileName);
    props.load(in);

    String drivers = props.getProperty("jdbc.drivers");
    if (drivers != null) System.setProperty("jdbc.drivers", drivers);
    String url = props.getProperty("jdbc.url");
    String username = props.getProperty("jdbc.username");
    String password = props.getProperty("jdbc.password");

    return DriverManager.getConnection(url, username, password);
  }
Exemple #17
0
 public static Connection ConnectionProvider() {
   try {
     Class.forName(prop.getProperty("driverClass"));
     Connection connection =
         DriverManager.getConnection(
             prop.getProperty("url"), prop.getProperty("userName"), prop.getProperty("password"));
     return connection;
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return null;
 }
Exemple #18
0
  /**
   * Gets a connection from the properties specified in the file database.properties
   *
   * @return the database connection
   */
  public static Connection getConnection() throws SQLException, IOException {
    Properties props = new Properties();
    try (InputStream in = Files.newInputStream(Paths.get("database.properties"))) {
      props.load(in);
    }

    String drivers = props.getProperty("jdbc.drivers");
    if (drivers != null) System.setProperty("jdbc.drivers", drivers);

    String url = props.getProperty("jdbc.url");
    String username = props.getProperty("jdbc.username");
    String password = props.getProperty("jdbc.password");

    return DriverManager.getConnection(url, username, password);
  }
Exemple #19
0
 private void resolveVariables(Context ctx, Properties initProps) {
   for (Map.Entry<Object, Object> entry : initProps.entrySet()) {
     if (entry.getValue() != null) {
       entry.setValue(ctx.replaceTokens((String) entry.getValue()));
     }
   }
 }
Exemple #20
0
 public static Connection getConnection(Connection c) throws Exception {
   Connection conn = c;
   if (c != null && !c.isClosed()) {
     return c;
   } else {
     Class clazz = Class.forName("org.luciddb.jdbc.LucidDbLocalDriver");
     LucidDbLocalDriver driver = (LucidDbLocalDriver) clazz.newInstance();
     String urlPrefix = driver.getUrlPrefix();
     Properties props = new Properties();
     props.setProperty("user", "sa");
     props.setProperty("password", "");
     props.setProperty("requireExistingEngine", "true");
     c = DriverManager.getConnection(urlPrefix, props);
   }
   return c;
 }
  private synchronized void maybeConnect() throws BlockStoreException {
    try {
      if (conn.get() != null) return;

      Properties props = new Properties();
      props.setProperty("user", this.username);
      props.setProperty("password", this.password);

      conn.set(DriverManager.getConnection(connectionURL, props));

      Connection connection = conn.get();
      allConnections.add(conn.get());
      log.info("Made a new connection to database " + connectionURL);
    } catch (SQLException ex) {
      throw new BlockStoreException(ex);
    }
  }
  public String[] getCleanSql() {
    if (cleanSql == null) {
      // loop over all foreign key constraints
      List dropForeignKeysSql = new ArrayList();
      List createForeignKeysSql = new ArrayList();
      Iterator iter = configuration.getTableMappings();
      while (iter.hasNext()) {
        Table table = (Table) iter.next();
        if (table.isPhysicalTable()) {
          Iterator subIter = table.getForeignKeyIterator();
          while (subIter.hasNext()) {
            ForeignKey fk = (ForeignKey) subIter.next();
            if (fk.isPhysicalConstraint()) {
              // collect the drop key constraint
              dropForeignKeysSql.add(
                  fk.sqlDropString(
                      dialect,
                      properties.getProperty(Environment.DEFAULT_CATALOG),
                      properties.getProperty(Environment.DEFAULT_SCHEMA)));
              createForeignKeysSql.add(
                  fk.sqlCreateString(
                      dialect,
                      mapping,
                      properties.getProperty(Environment.DEFAULT_CATALOG),
                      properties.getProperty(Environment.DEFAULT_SCHEMA)));
            }
          }
        }
      }

      List deleteSql = new ArrayList();
      iter = configuration.getTableMappings();
      while (iter.hasNext()) {
        Table table = (Table) iter.next();
        deleteSql.add("delete from " + table.getName());
      }

      List cleanSqlList = new ArrayList();
      cleanSqlList.addAll(dropForeignKeysSql);
      cleanSqlList.addAll(deleteSql);
      cleanSqlList.addAll(createForeignKeysSql);

      cleanSql = (String[]) cleanSqlList.toArray(new String[cleanSqlList.size()]);
    }
    return cleanSql;
  }
 // 采用静态初始化块来初始化Connection、Statement对象
 static {
   try {
     Properties props = new Properties();
     props.load(new FileInputStream("mysql.ini"));
     String drivers = props.getProperty("driver");
     String url = props.getProperty("url");
     String username = props.getProperty("user");
     String password = props.getProperty("pass");
     // 加载数据库驱动
     Class.forName(drivers);
     // 取得数据库连接
     conn = DriverManager.getConnection(url, username, password);
     stmt = conn.createStatement();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemple #24
0
  /**
   * Creates configuration properties object for new connection.
   *
   * <p>See GridGain client javadoc for more information: {@link GridClientConfiguration}.
   *
   * <p>All parameters are optional.
   *
   * @return Configuration.
   */
  private static Properties configuration() {
    Properties cfg = new Properties();

    // Node ID where to execute query. This property is useful when you have several
    // local caches with same name in topology and want to specify which of them to connect.
    //
    // Uncomment line below and provide correct ID if needed.
    //        cfg.setProperty(CONF_NODE_ID, "E0869485-512C-41F9-866D-BE906B591BEA");

    // Communication protocol (TCP or HTTP). Default is TCP.
    cfg.setProperty(CONF_PROTO, "TCP");

    // Socket timeout. Default is 0 which means infinite timeout.
    cfg.setProperty(CONF_TIMEOUT, "0");

    // Flag indicating whether TCP_NODELAY flag should be enabled for outgoing
    // connections. Default is true.
    cfg.setProperty(CONF_TCP_NO_DELAY, "true");

    // Flag indicating that SSL is needed for connection. Default is false.
    cfg.setProperty(CONF_SSL_ENABLED, "false");

    // SSL context factory class name. Class must extend
    // org.gridgain.client.ssl.GridSslContextFactory
    // interface, have default constructor and be available on classpath.
    // Ignored if SSL is disabled.
    cfg.setProperty(CONF_SSL_FACTORY, "org.gridgain.client.ssl.GridSslBasicContextFactory");

    // SSL pass-phrase.
    // Ignored is SSL is disabled.
    cfg.setProperty(CONF_CREDS, "s3cr3t");

    // Flag indicating that topology is cached internally. Cache will be refreshed
    // in the background with interval defined by CONF_TOP_REFRESH_FREQ property
    // (see below). Default is false.
    cfg.setProperty(CONF_TOP_CACHE_ENABLED, "false");

    // Topology cache refresh frequency. Default is 2000 ms.
    cfg.setProperty(CONF_TOP_REFRESH_FREQ, "2000");

    // Maximum amount of time that connection can be idle before it is closed.
    // Default is 30000 ms.
    cfg.setProperty(CONF_MAX_IDLE_TIME, "30000");

    return cfg;
  }
  private void initializeDatabaseContext() throws EmanagerDatabaseException {
    logger.debug("Enter");

    Properties properties;
    SybConnectionPoolDataSource poolDataSource;

    properties = new Properties();
    poolDataSource = new com.sybase.jdbc2.jdbc.SybConnectionPoolDataSource();

    poolDataSource.setUser(userAccount);
    poolDataSource.setPassword(password);
    poolDataSource.setDatabaseName(databaseName);
    poolDataSource.setServerName(databaseHost);
    poolDataSource.setPortNumber(connectionPort);
    poolDataSource.setDescription(connectionPoolDescription);

    properties.put("user", userAccount);
    properties.put("password", password);
    properties.put("APPLICATIONNAME", clientAppName);
    // fix
    // hopefully these have defaults
    // properties.put("USE_METADATA", userMetaData);
    // properties.put("REPEAT_READ", useRepeatRead);
    // properties.put("CHARSET_CONVERTER_CLASS", charsetConverter);

    properties.put("server", "jdbc:sybase:Tds:" + databaseHost + ":" + connectionPort);

    try {
      poolDataSource.setConnectionProperties(properties);
      // jndiContext.bind("jdbc/protoDB", poolDataSource);
      jndiContext.bind(JNDIContextName, poolDataSource);
    } catch (Exception ex) {
      String logString;
      EmanagerDatabaseException ede;

      logString =
          EmanagerDatabaseStatusCode.UnableToBindJNDIContext.getStatusCodeDescription()
              + ex.getMessage();

      logger.fatal(logString);
      ede =
          new EmanagerDatabaseException(
              EmanagerDatabaseStatusCode.UnableToBindJNDIContext, logString);
      throw ede;
    }
  }
 @Override
 public void setProperties(Properties properties) {
   String dialect = properties.getProperty("dialect");
   if (Strings.isNullOrEmpty(dialect)) {
     dialect = DEFAULT_DIALECT;
   }
   setDialect(dialect);
 }
Exemple #27
0
  static {
    prop = new Properties();
    try {
      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      prop.load(classLoader.getResourceAsStream("/DB.properties"));

      // prop.load(new FileInputStream("Database.properties"));
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Exemple #28
0
 private Properties getDatabaseProperties() {
   Properties props = new Properties();
   InputStream in = null;
   try {
     in = getClass().getResourceAsStream("db.properties");
     props.load(in);
   } catch (FileNotFoundException e) {
     System.out.println(Error.ERROR_DB_PROPERTIES_FILE_NOT_FOUND.getErrorText());
   } catch (IOException e) {
     System.out.println(Error.ERROR_DB_PROPERTIES_READ.getErrorText());
   } finally {
     if (in != null) {
       try {
         in.close();
       } catch (IOException e) {
         System.out.println(Error.ERROR_DB_PROPERTIES_FILE_NOT_FOUND.getErrorText());
       }
     }
   }
   return props;
 }
Exemple #29
0
  @Override
  public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
    checkCreate(qc);
    // URL to relational database
    final String url = string(toToken(exprs[0], qc));
    final JDBCConnections jdbc = jdbc(qc);
    try {
      if (exprs.length > 2) {
        // credentials
        final String user = string(toToken(exprs[1], qc));
        final String pass = string(toToken(exprs[2], qc));
        if (exprs.length == 4) {
          // connection options
          final Options opts = toOptions(3, Q_OPTIONS, new Options(), qc);
          // extract auto-commit mode from options
          boolean ac = true;
          final HashMap<String, String> options = opts.free();
          final String commit = options.get(AUTO_COMM);
          if (commit != null) {
            ac = Strings.yes(commit);
            options.remove(AUTO_COMM);
          }
          // connection properties
          final Properties props = connProps(options);
          props.setProperty(USER, user);
          props.setProperty(PASS, pass);

          // open connection
          final Connection conn = getConnection(url, props);
          // set auto/commit mode
          conn.setAutoCommit(ac);
          return Int.get(jdbc.add(conn));
        }
        return Int.get(jdbc.add(getConnection(url, user, pass)));
      }
      return Int.get(jdbc.add(getConnection(url)));
    } catch (final SQLException ex) {
      throw BXSQ_ERROR_X.get(info, ex);
    }
  }
Exemple #30
0
 private Properties decryptPwd(Properties initProps) {
   String encryptionKey = initProps.getProperty("encryptKeyFile");
   if (initProps.getProperty("password") != null && encryptionKey != null) {
     // this means the password is encrypted and use the file to decode it
     try {
       try (Reader fr = new InputStreamReader(new FileInputStream(encryptionKey), UTF_8)) {
         char[] chars = new char[100]; // max 100 char password
         int len = fr.read(chars);
         if (len < 6)
           throw new DataImportHandlerException(
               SEVERE, "There should be a password of length 6 atleast " + encryptionKey);
         Properties props = new Properties();
         props.putAll(initProps);
         String password = null;
         try {
           password =
               CryptoKeys.decodeAES(initProps.getProperty("password"), new String(chars, 0, len))
                   .trim();
         } catch (SolrException se) {
           throw new DataImportHandlerException(SEVERE, "Error decoding password", se.getCause());
         }
         props.put("password", password);
         initProps = props;
       }
     } catch (IOException e) {
       throw new DataImportHandlerException(
           SEVERE, "Could not load encryptKeyFile  " + encryptionKey);
     }
   }
   return initProps;
 }