Пример #1
0
  public static int whereCount(String subsql) {
    DBConnect dbc = null;
    int result = EXECUTE_FAIL;
    String sql = "select count(*) from tb_con_province where " + subsql + "";

    try {
      dbc = new DBConnect(sql);
      ResultSet rs = dbc.executeQuery();
      while (rs.next()) {
        return rs.getInt(1);
      }
      return EXECUTE_FAIL;
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (dbc != null) dbc.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return result;
  }
Пример #2
0
  public static List<TbConProvince> where(String subsql) {
    DBConnect dbc = null;
    String sql = "select * from tb_con_province where " + subsql + "";
    List<TbConProvince> list = new ArrayList<TbConProvince>();

    try {
      dbc = new DBConnect(sql);
      ResultSet rs = dbc.executeQuery();
      while (rs.next()) {
        TbConProvince tbconprovince = new TbConProvince();
        fill(rs, tbconprovince);
        list.add(tbconprovince);
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (dbc != null) dbc.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return list;
  }