Example #1
0
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody DataShop getShopInJSON(
      @RequestParam("lictype") String lictype, HttpSession session) throws Exception {
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;

    DataShop dataShop = new DataShop();
    List list = new ArrayList();
    List listX = new ArrayList();
    String s_drvschool = session.getAttribute("user").toString();
    try {
      Class.forName("org.postgresql.Driver").newInstance();
    } catch (Exception e) {
      System.out.print(e.getMessage());
    }
    DBInfo connstr = new DBInfo();
    String url = connstr.getUrl();
    String user = connstr.getUser();
    String password = connstr.getPassword();
    try {
      conn = DriverManager.getConnection(url, user, password);
      stmt = conn.createStatement();
      int i_num_tj = 0;

      String sql =
          "select  count(1) as num_tj " + " from work.qt_cont WHERE lictype='" + lictype + "'";

      rs = stmt.executeQuery(sql);
      while (rs.next()) {
        i_num_tj = rs.getInt(1);
        if (i_num_tj == 0 || rs.getString(1) == null) {
          dataShop.setSuccess(true);
        } else {
          dataShop.setSuccess(false);
        }
      }

    } catch (SQLException e) {
      System.out.print(e.getMessage());
    } finally {
      try {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
        if (conn != null) conn.close();
      } catch (SQLException e) {
        System.out.print(e.getMessage());
      }
    }

    //        dataShop.setList(list);

    return dataShop;
  }
Example #2
0
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody DataShop getShopInJSON(
      //            @PathVariable String user_id,
      @RequestParam("id") Integer id) throws Exception {
    DataShop dataShop = new DataShop();
    Connection conn = null;
    PreparedStatement pst = null;
    try {
      Class.forName("org.postgresql.Driver").newInstance();
    } catch (Exception e) {
      System.out.print(e.getMessage());
    }

    DBInfo connstr = new DBInfo();
    String url = connstr.getUrl();
    String user = connstr.getUser();
    String password = connstr.getPassword();

    try {
      conn = DriverManager.getConnection(url, user, password);

      String sql = "delete from work.users where id = ?";
      pst = conn.prepareStatement(sql);
      pst.setInt(1, id);

      pst.executeUpdate();

      dataShop.setSuccess(true);

    } catch (SQLException e) {
      System.out.print(e.getMessage());
    } finally {
      try {
        if (pst != null) pst.close();
        if (conn != null) conn.close();
      } catch (SQLException e) {
        System.out.print(e.getMessage());
      }
    }
    //        dataShop.setName(user_id);

    return dataShop;
  }
Example #3
0
  @RequestMapping(method = RequestMethod.POST)
  public @ResponseBody DataShop getShopInJSON(
      @RequestParam("id") Integer id,
      @RequestParam("name") String name,
      @RequestParam("sex") String sex,
      @RequestParam("card") String card,
      @RequestParam("address") String address,
      @RequestParam("lictype") String lictype,
      @RequestParam("licdt") String licdt,
      @RequestParam("licmd") String licmd,
      @RequestParam("status") String status,
      @RequestParam("auditdt") String auditdt,
      @RequestParam("auditps") String auditps,
      @RequestParam("remark") String remark)
      throws Exception {
    DataShop dataShop = new DataShop();
    dataShop.setSuccess(true);
    Connection conn = null;
    PreparedStatement pst = null;
    try {
      Class.forName("org.postgresql.Driver").newInstance();
    } catch (Exception e) {
      System.out.print(e.getMessage());
    }

    DBInfo connstr = new DBInfo();
    String url = connstr.getUrl();
    String user = connstr.getUser();
    String password = connstr.getPassword();

    try {
      conn = DriverManager.getConnection(url, user, password);
      String sql =
          "update work.examinees set "
              + "name=?, sex=?, card=?, address=?, lictype=?, licdt=?, licmd=?,status=?, "
              + "  auditdt=?,auditps=?,  remark=?"
              + "where id = ?";
      pst = conn.prepareStatement(sql);
      pst.setString(1, name);
      pst.setString(2, sex);
      pst.setString(3, card);
      pst.setString(4, address);
      pst.setString(5, lictype);
      java.sql.Date sql_licdt = null;
      if (licdt != null && licdt.length() > 2) sql_licdt = java.sql.Date.valueOf(licdt);
      pst.setDate(6, sql_licdt);
      pst.setString(7, licmd);
      pst.setString(8, status);
      java.sql.Date sql_auditdt = null;
      if (auditdt != null && auditdt.length() > 2) sql_auditdt = java.sql.Date.valueOf(auditdt);
      pst.setDate(9, sql_auditdt);
      pst.setString(10, auditps);
      pst.setString(11, remark);
      pst.setInt(12, id);
      pst.executeUpdate();

      dataShop.setSuccess(true);

    } catch (SQLException e) {
      System.out.print(e.getMessage());
    } finally {
      try {
        if (pst != null) pst.close();
        if (conn != null) conn.close();
      } catch (SQLException e) {
        System.out.print(e.getMessage());
      }
    }

    return dataShop;
  }