Exemplo n.º 1
0
  private static void insertRecords(final HConnection connection, final int cnt, final String msg)
      throws HBqlException {

    HPreparedStatement stmt =
        connection.prepareStatement(
            "insert into delete_test "
                + "(keyval, val1, val2, val3, val11, val12, val13, val21, val22, val23 ) values "
                + "(:key, :val1, :val2, :val3, :val11, :val12, :val13, :val21, :val22, :val23)");

    for (int i = 0; i < cnt; i++) {

      final String keyval = Util.getZeroPaddedNonNegativeNumber(i, TestSupport.keywidth);

      int randomNum = randomVal.nextInt();
      String randomStr = "" + randomNum;

      stmt.setParameter("key", keyval);
      stmt.setParameter("val1", randomStr);
      stmt.setParameter("val2", randomStr + " " + msg);
      stmt.setParameter("val3", randomStr + " " + msg + " " + msg);
      stmt.setParameter("val11", randomStr);
      stmt.setParameter("val12", randomStr + " " + msg);
      stmt.setParameter("val13", randomStr + " " + msg + " " + msg);
      stmt.setParameter("val21", randomStr);
      stmt.setParameter("val22", randomStr + " " + msg);
      stmt.setParameter("val23", randomStr + " " + msg + " " + msg);
      stmt.execute();
    }
  }
Exemplo n.º 2
0
  @Test
  public void simpleLimitSelect() throws HBqlException {

    List<AnnotatedAllTypes> vals = insertSomeData(cnt, true);

    assertTrue(vals.size() == cnt);

    HPreparedStatement pstmt =
        connection.prepareStatement("select * from alltypes2 WITH LIMIT :limit");

    pstmt.setParameter("limit", cnt / 2);

    HResultSet<AnnotatedAllTypes> recs = pstmt.executeQuery(AnnotatedAllTypes.class);

    int reccnt = 0;
    for (final AnnotatedAllTypes rec : recs) assertTrue(rec.equals(vals.get(reccnt++)));

    assertTrue(reccnt == cnt / 2);
  }