Ejemplo n.º 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;
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 3
0
 public static void fill(ResultSet rs, TbConProvince tbconprovince) throws SQLException {
   tbconprovince.setPid(rs.getInt("pid")); // 自增长主键 省列表
   tbconprovince.setPname(rs.getString("pname")); //
 }