Beispiel #1
0
  @Override
  public ArrayList<User> getAll(int limit, int offset) {
    ArrayList<User> result = new ArrayList<>();
    String sql = "select * from user limit ? offset ?";
    Connection con = new ConnectionPool().getConnection();
    PreparedStatement ps;
    try {
      ps = con.prepareStatement(sql);
      ps = con.prepareStatement("select * from user limit ? offset ?");
      ps.setInt(1, limit);
      ps.setInt(2, offset);
      ResultSet rs = ps.executeQuery();
      while (rs.next()) {
        User user = new User();
        user.setIdUser(rs.getString("idUser"));
        user.setFullName(rs.getString("fullName"));
        user.setEmail(rs.getString("email"));
        user.setUserName(rs.getString("userName"));
        user.setPhone(rs.getString("phone"));
        user.setAddress(rs.getString("address"));
        user.setImg(rs.getString("img"));
        user.setActive(rs.getInt("active"));
        result.add(user);
      }

      rs.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    return result;
  }
Beispiel #2
0
 private static User constructUserFromResultSet(ResultSet rs) {
   try {
     User user = new User();
     user.setUid(Integer.parseInt(rs.getString("uid")));
     user.setUserName(rs.getString("userName"));
     user.setPassword(rs.getString("password"));
     user.setEmail(rs.getString("email"));
     return user;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return null;
 }
  protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    User u = new User();
    UserDAO userDao = new UserDAO();
    u.setUserName(request.getParameter("user"));
    u.setPassword(request.getParameter("password"));
    u.setEmail(request.getParameter("email"));
    userDao.AddUser(u);

    RequestDispatcher rd = request.getRequestDispatcher("/home.jsp");

    try {
      rd.forward(request, response);
    } catch (ServletException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public void testgetExcelList()
      throws NoSuchMethodException, IllegalAccessException, IllegalArgumentException,
          InvocationTargetException, IOException, InstantiationException {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
    // 从spring配置文件中获取对象
    CustomSQLService customSQLService = (CustomSQLService) ctx.getBean("CustomSQLService");

    User user = new User();
    user.setUserName("武汉市市本级");
    user.setUpperDistrict("武汉市");
    user.setDistrictName("市本级");
    String sql = "select top 100000 * from DSDATA.基础表_纳税人基本信息表";
    System.out.println("sql:" + sql);

    List<CustomSQLModel> analyList = customSQLService.getExcelList(sql.trim(), 80000, 40000, user);
    System.out.println(analyList.size());
    /*for(CustomSQLModel s:analyList){

    }*/

  }
Beispiel #5
0
 @Override
 public User getUser(String email) {
   String sql = "select * from user where email = ?";
   Connection c = new ConnectionPool().getConnection();
   User us = new User();
   try {
     PreparedStatement sqlui = c.prepareStatement(sql);
     sqlui.setString(1, email);
     ResultSet rs = sqlui.executeQuery();
     if (rs.next()) {
       us.setIdUser(rs.getString("idUser"));
       us.setFullName(rs.getString("fullName"));
       us.setUserName(rs.getString("userName"));
       us.setEmail(rs.getString("email"));
       us.setImg(rs.getString("img"));
       us.setPhone(rs.getString("phone"));
       us.setAddress(rs.getString("address"));
     }
     rs.close();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return us;
 }