思考: 提起分页查询,想必任何一个开发人员(不论是新手还是老手)都能快速编码实现,实现原理再简单不过,无非就是写一条SELECT查询的SQL语句,ORDER BY分页排序的字段, 再结合limit (页码-1),每页记录数,这样即可返回指定页码的分页记录,类似SQL如下所示: select * from table where 查询条件 order by id limit 100,100; -- 这里假设是第2页(limit 第1个值从0开始),每页100条 那如果是想将多张表的记录合并一起进行
一.实体查询 using MyOrm.Commons; using MyOrm.DbParameters; using MyOrm.Expressions; using MyOrm.Mappers; using MyOrm.Reflections; using MyOrm.SqlBuilder; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using
public class PageList<T> { private int totalpage; //总页数 private int totalcount; //总记录数 private int currentpage; //当前页 private int pagesize; //每页的数量 private int firstpage; //第一页 private int lastpage; //最后一页 private int prepage; //上一页 private int next
什么时候自己创建工具类 如果一个功能经常用到 我们建议把这个功能做成工具类 创建JdbcUtils包含三个方法 1: 把几个字符串 定义为常量 2:得到数据库连接getConnection(); 3 关闭和打开资源 package JdbcUtils; import java.sql.*; public class JdbcUtilsDemo { public static final String USER = "root"; public static final String P
jdbc.properties数据库配置的属性文件内容如下 jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost/xxxxx?seUnicode=true&characterEncoding=UTF8 jdbc.username=root jdbc.password=xxxxxx JDBCUtils工具类的代码如下 public class JDBCUtils { private static final String