资源简介
千里之行购物网站(JAVA+SQL),分前台和后台,java+sql+myeclipes+tomcat,初学者可以拿去借鉴
代码片段和文件信息
package com.hujingxiang.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import com.hujingxiang.entity.BulletinInfo;
import com.hujingxiang.entity.User;
import com.hujingxiang.util.ConnDB;
import com.hujingxiang.util.DateTimeUtil;
import com.hujingxiang.util.PageModel;
public class BulletinDao {
public PageModel getAllBulletinInfo(int pageSizeint pageNo){
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
PageModel pm=null;
ArrayList items=new ArrayList();
String sql=“select top “ +pageSize+ “ a.*b.userName from Bulletin a “ +
“inner join UserInfo b on a.userId=b.id where a.id “ +
“not in (select top “ +((pageNo-1)*pageSize)+ “ id from Bulletin)“;
try {
conn=ConnDB.getConn();
pstmt=conn.prepareStatement(sql);
//执行查询
rs=pstmt.executeQuery();
BulletinInfo item=null;
User user=null;
while(rs.next()){
item=new BulletinInfo();
item.setId(rs.getInt(“id“));
item.settitle(rs.getString(“title“));
item.setContent(rs.getString(“content“));
user=new User();
user.setUserID(rs.getInt(“userId“));
user.setUserName(rs.getString(“userName“));
item.setUser(user);
item.setCreateTime((Date)rs.getobject(“createTime“));
items.add(item);
}
pm=new PageModel();
pm.setData(items);
pm.setPageNo(pageNo);
pm.setPageSize(pageSize);
pm.setTotalRecords(getTotalRecords(connpstmtrs));
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnDB.closeConn(conn pstmt rs);
}
return pm;
}
//获取总记录条数
private int getTotalRecords(Connection conn PreparedStatement pstmt
ResultSet rs) {
String sql=“select count(1) from Bulletin“;
int count=0;
try {
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
if(rs.next()){
count=rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
return count;
}
/*
* 公告信息关键词查询(分页)
*/
public PageModel getAllBulletinInfo(int pageSizeint pageNoString keywords) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
PageModel pm = null;
ArrayList items = new ArrayList();
String sql = “select top “+pageSize+“ a.*b.userName from Bulletin a inner join UserInfo b on a.userId=b.id where a.title like ‘%“+keywords+“%‘ and a.id not in (select top “+((pageNo-1)*pageSize)+“ id from Bulletin)“;
try {
conn = ConnDB.getConn();
pstmt = conn.prepareStatement(sql);
// 执行查询
rs = pstmt.executeQuery();
BulletinInfo item = null;
User user = null;
while (rs.next()) {
item = new BulletinInfo();
item.setId(rs.getInt(“id“));
ite
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-10-13 14:54 qlzx\
文件 432 2010-09-15 16:47 qlzx\.classpath
目录 0 2010-09-15 16:46 qlzx\.myeclipse\
文件 285 2010-10-29 14:36 qlzx\.myme
文件 1277 2010-09-27 13:30 qlzx\.project
目录 0 2021-01-01 18:26 qlzx\src\
目录 0 2021-01-01 18:26 qlzx\src\com\
目录 0 2021-01-01 18:27 qlzx\src\com\hujingxiang\
目录 0 2010-10-08 14:57 qlzx\src\com\hujingxiang\dao\
文件 9155 2010-10-11 14:44 qlzx\src\com\hujingxiang\dao\BulletinDao.java
文件 13490 2010-10-11 14:45 qlzx\src\com\hujingxiang\dao\CustomerInfoDao.java
文件 17422 2010-10-29 15:20 qlzx\src\com\hujingxiang\dao\GoodsInfoDao.java
文件 9391 2010-10-29 15:18 qlzx\src\com\hujingxiang\dao\GoodsTypeDao.java
文件 14447 2010-10-11 14:07 qlzx\src\com\hujingxiang\dao\OrderInfoDao.java
文件 4276 2010-09-27 16:10 qlzx\src\com\hujingxiang\dao\UserDao.java
目录 0 2010-10-29 15:27 qlzx\src\com\hujingxiang\entity\
文件 1180 2010-09-26 15:37 qlzx\src\com\hujingxiang\entity\BulletinInfo.java
文件 2560 2010-10-29 16:52 qlzx\src\com\hujingxiang\entity\Cart.java
文件 1149 2010-10-08 15:02 qlzx\src\com\hujingxiang\entity\CustomerDetailInfo.java
文件 1049 2010-10-08 15:02 qlzx\src\com\hujingxiang\entity\CustomerInfo.java
文件 2160 2010-10-08 00:38 qlzx\src\com\hujingxiang\entity\GoodsInfo.java
文件 862 2010-10-08 00:29 qlzx\src\com\hujingxiang\entity\GoodsType.java
文件 893 2010-10-08 15:03 qlzx\src\com\hujingxiang\entity\OrderGoodsInfo.java
文件 1205 2010-10-08 15:04 qlzx\src\com\hujingxiang\entity\OrderInfo.java
文件 578 2007-01-01 07:53 qlzx\src\com\hujingxiang\entity\SalesGoods.java
文件 969 2010-09-06 15:06 qlzx\src\com\hujingxiang\entity\User.java
目录 0 2010-10-30 16:28 qlzx\src\com\hujingxiang\servlet\
文件 931 2010-10-30 16:29 qlzx\src\com\hujingxiang\servlet\AjaxGetIsEmailExists.java
文件 6875 2010-10-13 14:40 qlzx\src\com\hujingxiang\servlet\BulletinManage.java
文件 4251 2010-10-29 17:00 qlzx\src\com\hujingxiang\servlet\CartManage.java
文件 5447 2010-10-30 15:02 qlzx\src\com\hujingxiang\servlet\CustomerForwardManage.java
............此处省略269个文件信息
评论
共有 条评论