LeaverecordsSys.rar

  • 爱牙小宝宝
    了解作者
  • HTML
    开发工具
  • 939KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 1
    下载次数
  • 2018-09-20 20:11
    上传日期
使用分页显示数据库信息,使页面更整洁,运行更高效
LeaverecordsSys.rar
内容介绍
package dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import entity.LeaveRecords; public class LeaveRecordsDaoImpl extends BaseDao implements LeaveRecordsDao { /*@Override public List<LeaveRecords> getAll() { String sql="SELECT * FROM leaverecords ORDER BY leaveTime"; Connection conn=getConnection(); PreparedStatement ps=null; ResultSet rs=null; List<LeaveRecords> records=new ArrayList<>(); try { ps=conn.prepareStatement(sql); rs=ps.executeQuery(); while (rs.next()) { LeaveRecords records2=new LeaveRecords(); records2.setId(rs.getInt("id")); records2.setName(rs.getString("name")); records2.setLeaveTime(rs.getDate("leaveTime")); records2.setReason(rs.getString("reason")); records.add(records2); } return records; } catch (SQLException e) { e.printStackTrace(); }finally { CloseAll(conn, ps, rs); } return null; }*/ @Override public int add(LeaveRecords lRecords) { String sql="INSERT INTO leaverecords(`name`,`leaveTime`,`reason`) VALUES (?,?,?);"; Connection conn=getConnection(); PreparedStatement ps=null; try { ps=conn.prepareStatement(sql); ps.setObject(1, lRecords.getName()); ps.setObject(2, lRecords.getLeaveTime()); ps.setObject(3, lRecords.getReason()); int num=ps.executeUpdate(); return num; } catch (SQLException e) { e.printStackTrace(); }finally { CloseAll(conn, ps, null); } return -1; } @Override public int delete(int id) { String sql="DELETE FROM leaverecords WHERE id=?"; Connection conn=getConnection(); PreparedStatement ps=null; try { ps=conn.prepareStatement(sql); ps.setObject(1, id); int num=ps.executeUpdate(); return num; } catch (SQLException e) { e.printStackTrace(); }finally { CloseAll(conn, ps, null); } return -1; } @Override public List<LeaveRecords> getPages(int currentPage, int pageSize) { Connection conn = getConnection(); String sql = "SELECT * FROM leaverecords LIMIT ?,?"; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(sql); ps.setObject(1,currentPage); ps.setObject(2,pageSize); rs = ps.executeQuery(); List<LeaveRecords> pList = new ArrayList<>(); System.out.println("3434334335----"); while (rs.next()) { LeaveRecords records = new LeaveRecords(); records.setId(rs.getInt("id")); records.setName(rs.getString("name")); records.setLeaveTime(rs.getDate("leaveTime")); records.setReason(rs.getString("reason")); pList.add(records); } return pList; } catch (SQLException e) { e.printStackTrace(); } finally { CloseAll(conn, ps, rs); } return null; } @Override public int seleteCount() { String sql="SELECT count(1) FROM leaverecords "; Connection conn=getConnection(); PreparedStatement ps=null; ResultSet rs = null; try { ps=conn.prepareStatement(sql); rs = ps.executeQuery(); int count=-1; if (rs.next()) { count=rs.getInt(1); } return count; } catch (SQLException e) { e.printStackTrace(); }finally { CloseAll(conn, ps, rs); } return -1; } }
评论
    相关推荐
    • jsp分页
      NULL 博文链接:https://qwnbc.iteye.com/blog/1601386
    • jsp分页
      用Eclipse写的
    • jsp分页
      一个用jbuilder写的jsp 分页的例子,里面有数据库脚本,
    • jsp分页
      完全是MVC模式。JBDUILER+SQL2000写的,数据库名为pubs,表名pageTab,建立3个字段,因为是数组写的,所以不需要分类型!
    • jsp分页
      NULL 博文链接:https://machuanhai.iteye.com/blog/416226
    • jsp分页
      NULL 博文链接:https://qwnbc.iteye.com/blog/1601386
    • jsp分页
      是 一个可运行的分页例子 稍微修改一下链接数据库的部分就可以了
    • jsp分页组件
      通用的jsp分页组件,实例化后只需设置好各种属性,然后调用API即可得到已封装好“首页” “上一页”,“下一页”等分页操作的html表格String,直接在jsp页面中即可, 支持跳转到jsp和跳转到Action(struts架构)...
    • jsp分页
      NULL 博文链接:https://paction520.iteye.com/blog/667738
    • JSP 分页
      NULL 博文链接:https://oracle-api.iteye.com/blog/2053729