首页>代码>jsp+servlet+jdbc实现的java web共享租车信息管理系统,包括登陆注册,页面框架Easy UI>/SharingCarRental/src/cn/edu/lingnan/dao/CompanyDao.java
package cn.edu.lingnan.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import cn.edu.lingnan.model.Company; import cn.edu.lingnan.model.PageBean; import cn.edu.lingnan.util.StringUtil; public class CompanyDao { public ResultSet companyList(Connection con,PageBean pageBean,Company company)throws Exception{ StringBuffer sb=new StringBuffer("select * from t_company"); if(company!=null && StringUtil.isNotEmpty(company.getCompanyName())){ sb.append(" and companyName like '%"+company.getCompanyName()+"%'"); } if(pageBean!=null){ sb.append(" limit "+pageBean.getStart()+","+pageBean.getRows()); } PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where")); return pstmt.executeQuery(); } public int companyCount(Connection con,Company company)throws Exception{ StringBuffer sb=new StringBuffer("select count(*) as total from t_company"); if(StringUtil.isNotEmpty(company.getCompanyName())){ sb.append(" and companyName like '%"+company.getCompanyName()+"%'"); } PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where")); ResultSet rs=pstmt.executeQuery(); if(rs.next()){ return rs.getInt("total"); }else{ return 0; } } /** * * delete from tableName where field in (1,3,5) * @param con * @param delIds * @return * @throws Exception */ public int companyDelete(Connection con,String delIds)throws Exception{ String sql="delete from t_company where id in("+delIds+")"; PreparedStatement pstmt=con.prepareStatement(sql); return pstmt.executeUpdate(); } public int companyAdd(Connection con,Company company)throws Exception{ String sql="insert into t_company values(null,?,?)"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, company.getCompanyName()); pstmt.setString(2, company.getCompanyDesc()); return pstmt.executeUpdate(); } public int companyModify(Connection con,Company company)throws Exception{ String sql="update t_company set companyName=?,companyDesc=? where id=?"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, company.getCompanyName()); pstmt.setString(2, company.getCompanyDesc()); pstmt.setInt(3, company.getId()); return pstmt.executeUpdate(); } }

微笑刺客 LV21
2024年11月22日
25jsiahs LV2
2024年6月26日
北方菜 LV11
2022年12月21日
飞翔的面包片 LV13
2022年12月12日
yy0987 LV5
2022年8月7日
AlanLi LV19
2022年8月2日
不忘初心砥砺前行 LV7
2022年6月30日
酒酒清欢 LV8
2022年6月15日
CHENHAOJUDA LV10
2022年6月14日
v6ulfWZ7pVjbex LV1
2022年6月11日

renjunyou LV10
6月2日
lkke23047 LV1
5月28日
哈哈哈123123
3月23日
暂无贡献等级
java小书童 LV18
3月19日
lj1748285
2024年12月30日
暂无贡献等级
dengjianer
2024年12月18日
暂无贡献等级
wzd031105 LV2
2024年12月6日
微笑刺客 LV21
2024年11月22日
xianyu091012 LV5
2024年11月18日
shunlun8855 LV1
2024年10月28日