Exemplo n.º 1
0
 private void readFile(File cmdFile) {
   try {
     FileInputStream fis = new FileInputStream(cmdFile);
     BufferedReader br = new BufferedReader(new InputStreamReader(fis));
     String s;
     while ((s = br.readLine()) != null) {
       super.doCommand(s);
     }
     br.close();
   } catch (IOException ex) {
     ex.printStackTrace();
   }
 }
Exemplo n.º 2
0
  private void initSession(Session session, ConnectionInfo ci) {
    boolean ignoreUnknownSetting = ci.getProperty("IGNORE_UNKNOWN_SETTINGS", false);
    String init = ci.getProperty("INIT", null);

    session.setAllowLiterals(true);
    CommandInterface command;
    for (String setting : ci.getKeys()) {
      if (SetTypes.contains(setting)) {
        String value = ci.getProperty(setting);
        try {
          command =
              session.prepareCommandLocal(
                  "SET " + session.getDatabase().quoteIdentifier(setting) + " " + value);
          command.executeUpdate();
        } catch (DbException e) {
          if (!ignoreUnknownSetting) {
            session.close();
            throw e;
          }
        }
      }
    }
    if (init != null) {
      try {
        command = session.prepareCommand(init, Integer.MAX_VALUE);
        command.executeUpdate();
      } catch (DbException e) {
        if (!ignoreUnknownSetting) {
          session.close();
          throw e;
        }
      }
    }
    session.setAllowLiterals(false);
    session.commit(true);
  }