예제 #1
0
파일: test.java 프로젝트: khelsen/jacob
  public static void printRS(Recordset rs) {
    Fields fs = rs.getFields();

    for (int i = 0; i < fs.getCount(); i++) {
      System.out.print(fs.getItem(i).getName() + " ");
    }
    System.out.println("");

    rs.MoveFirst();
    while (!rs.getEOF()) {
      for (int i = 0; i < fs.getCount(); i++) {
        Field f = fs.getItem(i);
        Variant v = f.getValue();
        System.out.print(v + " ");
      }
      System.out.println("");
      rs.MoveNext();
    }
  }
예제 #2
0
  /* (non-Javadoc)
   * @see dinamica.AbstractValidator#isValid(javax.servlet.http.HttpServletRequest, dinamica.Recordset, java.util.HashMap)
   */
  public boolean isValid(
      HttpServletRequest req, Recordset inputParams, HashMap<String, String> attribs)
      throws Throwable {

    boolean bParam = attribs.containsKey("parameter");
    if (!bParam)
      throw new Throwable(
          "[" + this.getClass().getName() + "] Missing attribute [parameter] in validator.xml");

    boolean bRule = attribs.containsKey("rule");
    if (!bRule)
      throw new Throwable(
          "[" + this.getClass().getName() + "] Missing attribute [rule] in validator.xml");

    String rule = (String) attribs.get("rule");

    if (!rule.equalsIgnoreCase("like") && !rule.equalsIgnoreCase("contains"))
      throw new Throwable(
          "["
              + this.getClass().getName()
              + "] Invalid attribute value [rule] in validator.xml: "
              + rule
              + " - Accepted values are 'like' or 'contains'");

    String paramName = (String) attribs.get("parameter");
    if (!inputParams.isNull(paramName)) {
      String value = inputParams.getString(paramName);
      value = StringUtil.replace(value, "%", "");
      if (rule.equalsIgnoreCase("like")) value = value + "%";
      if (rule.equalsIgnoreCase("contains")) value = "%" + value + "%";
      inputParams.setValue(paramName, value);
    } else {
      boolean x = attribs.containsKey("ifnull");
      if (x) {
        String value = (String) attribs.get("ifnull");
        inputParams.setValue(paramName, value);
      }
    }

    return true;
  }
예제 #3
0
파일: test.java 프로젝트: khelsen/jacob
 // open a recordset directly
 public static void getRS(String con, String query) {
   System.out.println("Recordset Open");
   Recordset rs = new Recordset();
   rs.Open(new Variant(query), new Variant(con));
   printRS(rs);
 }