Exemplo n.º 1
0
 public static int save(DBConnect dbc, TbConProvince tbconprovince) throws Exception {
   int result = EXECUTE_FAIL;
   String sql = "insert into tb_con_province(`pid`,`pname`) values(?,?)";
   dbc.prepareStatement(sql);
   dbc.setInt(1, tbconprovince.getPid());
   dbc.setString(2, tbconprovince.getPname());
   dbc.executeUpdate();
   result = EXECUTE_SUCCESSS;
   return result;
 }
Exemplo n.º 2
0
 public static int delete(DBConnect dbc, String subsql) {
   int result = EXECUTE_FAIL;
   String sql = "delete from tb_con_province where " + subsql + "";
   try {
     dbc.prepareStatement(sql);
     dbc.executeUpdate();
     result = EXECUTE_SUCCESSS;
   } catch (Exception e) {
     e.printStackTrace();
   }
   return result;
 }
Exemplo n.º 3
0
 public static int delete(String subsql) {
   int result = EXECUTE_FAIL;
   DBConnect dbc = null;
   String sql = "delete from tb_con_province where " + subsql + "";
   try {
     dbc = new DBConnect();
     dbc.prepareStatement(sql);
     dbc.executeUpdate();
     dbc.close();
     result = EXECUTE_SUCCESSS;
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       if (dbc != null) dbc.close();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return result;
 }
Exemplo n.º 4
0
 public static int update(DBConnect dbc, TbConProvince tbconprovince) throws Exception {
   int result = EXECUTE_FAIL;
   StringBuffer sb = new StringBuffer();
   sb.append("update tb_con_province set ");
   boolean flag = false;
   if (tbconprovince.COLUMN_FLAG[0]) {
     if (flag) {
       sb.append(",pid=?");
     } else {
       sb.append("pid=?");
       flag = true;
     }
   }
   if (tbconprovince.COLUMN_FLAG[1]) {
     if (flag) {
       sb.append(",pname=?");
     } else {
       sb.append("pname=?");
       flag = true;
     }
   }
   sb.append(" where pid=?");
   dbc = new DBConnect();
   dbc.prepareStatement(sb.toString());
   int k = 1;
   if (tbconprovince.COLUMN_FLAG[0]) {
     dbc.setInt(k, tbconprovince.getPid());
     k++;
   }
   if (tbconprovince.COLUMN_FLAG[1]) {
     dbc.setString(k, tbconprovince.getPname());
     k++;
   }
   dbc.setInt(k, tbconprovince.getPid());
   dbc.executeUpdate();
   dbc.close();
   result = EXECUTE_SUCCESSS;
   return result;
 }