示例#1
0
 public List<T> get(WhereUtil wUtil, String orderby) throws Exception {
   Connection conn = null;
   ResultSet rSet = null;
   List<T> t = null;
   try {
     conn = DBManager.getConnection();
     String sql = String.format("select * from %s  %s", getTableName(), wUtil.getWhere());
     if (orderby != null) {
       sql = String.format("%s %s", sql, orderby);
     }
     rSet = execSql(sql, conn, wUtil.getParams());
     if (null == rSet) {
       return null;
     } else {
       @SuppressWarnings("unchecked")
       ResultSetToObject<T> rObject = new ResultSetToObject<T>();
       t = rObject.mapRersultSetToList(rSet);
       return t;
     }
   } catch (Exception e) {
     // TODO: handle exception
   } finally {
     DBManager.freeConnection(conn);
   }
   return t;
 }
示例#2
0
 public long getTotalCount(String sql, WhereUtil wUtil) {
   Connection conn = null;
   long count = 0l;
   try {
     sql = String.format("%s %s", sql, wUtil.getWhere());
     count = getTotalCount(sql, conn, wUtil.getParams());
   } catch (Exception e) {
     // TODO: handle exception
   } finally {
     DBManager.freeConnection(conn);
   }
   return count;
 }
示例#3
0
 public long getTotalCount(WhereUtil wUtil) {
   Connection conn = null;
   long count = 0l;
   try {
     String sql =
         String.format(
             "select count(%s) from %s  %s", getTablePK(), getTableName(), wUtil.getWhere());
     count = getTotalCount(sql, conn, wUtil.getParams());
   } catch (Exception e) {
     // TODO: handle exception
   } finally {
     DBManager.freeConnection(conn);
   }
   return count;
 }
示例#4
0
 public Pagination<T> findListByPages(
     Pagination<T> pagination, WhereUtil whereUtil, String orderby) {
   String sql = String.format("select * from %s %s", getTableName(), whereUtil.getWhere());
   return findListByPages(pagination, sql, orderby, whereUtil.getParams());
 }
示例#5
0
 public long getTotalCount(WhereUtil wUtil, Connection connection) throws SQLException {
   String sql =
       String.format(
           "select count(%s) from %s  %s", getTablePK(), getTableName(), wUtil.getWhere());
   return getTotalCount(sql, connection, wUtil.getParams());
 }