Beispiel #1
0
  @Test
  public void testBuildObjects() throws SQLException {
    Db db = IciqlSuite.openNewDb();
    db.insertAll(Product.getList());

    // test plain statement
    ResultSet rs = db.executeQuery("select * from product where unitsInStock=120");
    List<Product> products = db.buildObjects(Product.class, rs);
    JdbcUtils.closeSilently(rs, true);

    assertEquals(1, products.size());
    assertEquals("Condiments", products.get(0).category);

    // test prepared statement
    rs = db.executeQuery("select * from product where unitsInStock=?", 120);
    products = db.buildObjects(Product.class, rs);
    JdbcUtils.closeSilently(rs, true);

    assertEquals(1, products.size());
    assertEquals("Condiments", products.get(0).category);

    db.close();
  }