Package org.apache.commons.dbutils.handlers

Examples of org.apache.commons.dbutils.handlers.BeanListHandler


  {
    try
    {
      return (List<T>) _g_runner.query(getConnection(), sql,
          _IsPrimitive(beanClass) ? _g_columnListHandler
              : new BeanListHandler(beanClass), params);
    }
    catch (SQLException e)
    {
      throw new DBException(e);
    }
View Full Code Here


    *           Class to bind object to.
    * @return List
    */
   public List getList(final String sql, final Class clazz) {
      try{
         final ResultSetHandler bean = new BeanListHandler(clazz);
         return (List) runner.query(conn, sql, null, bean);
      }catch (final SQLException e){
         if(GlobalSettings.logActive)
            new LogEngine().logMessage(e.getStackTrace().toString(), GlobalSettings.logPath, "ERROR");
         throw new RuntimeException(e);
View Full Code Here

  @SuppressWarnings("rawtypes")
  public static <T> List<T> query(Class<T> beanClass, String sql,
      Object... params) throws SQLException {
      return (List<T>) _runner.query(getConnection(), sql,
                _IsPrimitive(beanClass) ? _columnListHandler
                        : new BeanListHandler(beanClass), params);
  }
View Full Code Here

  @SuppressWarnings({ "unchecked", "rawtypes" })
  public  <T> List<T> queryForList(Class<T> entityClass, String sql, Object[] params) {
    List<T> list = new ArrayList<T>();
    try {
      if (params == null) {
        list = (List<T>) qr.query(sql, new BeanListHandler(
            entityClass));
      } else {
        list = (List<T>) qr.query(sql, new BeanListHandler(
            entityClass), params);
      }
    } catch (Exception e) {
      System.err.println("��ѯ�����쳣!ԭ��:" + e);
    }
View Full Code Here

        + id;
    QueryRunner qr = DbHelper.getQueryRunner();
    List list = null;
    Comment comment = null;
    try {
      list = (List) qr.query(sql, new BeanListHandler(Comment.class));
      comment = (Comment) list.get(0);
    } catch (SQLException e) {
      e.printStackTrace();
    }
    request.setAttribute("comment", comment);
View Full Code Here

    String sql = "select comment_id as id,comment_username as username,comment_content as content ,comment_created_time as createdTime from comment order by comment_id desc";
    QueryRunner qr = DbHelper.getQueryRunner();
    List list = null;
    try {
      list = (List) qr.query(sql, new BeanListHandler(Comment.class));
    } catch (SQLException e) {
      e.printStackTrace();
    }
    request.setAttribute("list", list);
    request.getRequestDispatcher("/admin/adminCommentList.jsp").forward(
View Full Code Here

    List list = null;
    User user = null;
    // 获取用户信息
    try {
      list = (List) qr
          .query(sql, new BeanListHandler(User.class), params);
    } catch (SQLException e) {
      e.printStackTrace();
    }
    // 判断是否合法用户 并把User对象放入Session中
    if (list.size() > 0) {
View Full Code Here

  @SuppressWarnings("rawtypes")
  public static <T> List<T> query(Class<T> beanClass, String sql,
      Object... params) throws SQLException {
      return (List<T>) _runner.query(getConnection(), sql,
                _IsPrimitive(beanClass) ? _columnListHandler
                        : new BeanListHandler(beanClass), params);
  }
View Full Code Here

     * Utils methods for map results of queries to customized beans or java.Util.Map
     **/
   
  @SuppressWarnings("unchecked")
  public List findListOfBeans(String sql, Object[] filterKeys, Class beanClass) { 
        return (List) executeQuery(sql, filterKeys, new BeanListHandler(beanClass));
    }
View Full Code Here

            String sql = "select category_id as id,category_name as name,category_level as level from category order by category_level desc, category_id desc";
            QueryRunner qr = DbHelper.getQueryRunner();
            List list = null;
            try {
                list = (List) qr.query(sql, new BeanListHandler(Category.class));
            } catch (SQLException e) {

                e.printStackTrace();
            }
            request.setAttribute("list", list);
View Full Code Here

TOP

Related Classes of org.apache.commons.dbutils.handlers.BeanListHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.