package com;
import java.util.ArrayList;
import java.util.Collection;
import java.sql.*;
public class GoodsBean {
private Connection con;
PageNumber pageNumber=new PageNumber();
int rowCount=1; //总的记录数
int showPage=16;//设置欲显示的页码数
int pageCount=1;//分页之后的总页数
//构造函数中建立数据库连接
public GoodsBean(){
try{
con=DBConnection.getConnection();
}catch(Exception e){
e.printStackTrace();
}
}
public int getRowCount(){
return rowCount;
}
//定义获得全部查询商品信息的方法
public int getAllPage(){
try{
Statement statement=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=statement.executeQuery("select * from Goods");
resultset.last();
rowCount=resultset.getRow();
pageNumber.setPageCount(rowCount, showPage);
pageCount=pageNumber.getPageCount();
}catch(Exception e){
e.printStackTrace();
}
return pageCount;
}
//定义根据商品类型获得商品信息的方法
public int getAllPageBySort(String s){
try{
Statement statement=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=statement.executeQuery("select * from Goods where sortName='"+s+"'");
resultset.last();
rowCount=resultset.getRow();
pageNumber.setPageCount(rowCount,showPage);
pageCount=pageNumber.getPageCount();
}catch(Exception e){
e.printStackTrace();
}
return pageCount;
}
//定义根据商品价格获得商品信息的方法
public int getAllPageByPrice(String s){
int a=s.indexOf("-");
float one=Float.parseFloat(s.substring(0,a));
float two=Float.parseFloat(s.substring(a+1));
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods where goodsPrice between "+one+" and "+two);
resultset.last();
rowCount=resultset.getRow();
pageNumber.setPageCount(rowCount,showPage);
pageCount=pageNumber.getPageCount();
}catch(Exception e){
e.printStackTrace();
}
return pageCount;
}
//定义分页显示所有商品信息的方法
public Collection getAllGoods(int s){
GoodsClass goods;
ArrayList arraylist=new ArrayList();
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods");
int count=0;
if(s!=0){
resultset.absolute(s*16);
}
while(resultset.next())
{
goods = new GoodsClass();
int i=resultset.getInt(1);
String s1=resultset.getString(2);
String s2=resultset.getString(3);
float f=resultset.getFloat(4);
String s5=resultset.getString(5);
String s6=resultset.getString(6);
goods.setGoodsId(i);
goods.setGoodsName(s1);
goods.setGoodsLanguage(s2);
goods.setGoodsPrice(f);
goods.setGoodsCent(s5);
goods.setSortName(s6);
arraylist.add(goods);
count++;
if(count==16)
{
break;
}
}
con.close();
}catch(Exception e){
e.printStackTrace();
}
return arraylist;
}
//定义分页显示根据商品类型获得商品信息的方法
public Collection getGoodsBySort(String s,int pageCount){
GoodsClass goods;
ArrayList arraylist=new ArrayList();
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods where sortName='"+s+"'");
int count=0;
if(pageCount!=0){
resultset.absolute(pageCount*16);
}
while(resultset.next())
{
goods = new GoodsClass();
int i=resultset.getInt(1);
String s1=resultset.getString(2);
String s2=resultset.getString(3);
float f=resultset.getFloat(4);
String s5=resultset.getString(5);
String s6=resultset.getString(6);
goods.setGoodsId(i);
goods.setGoodsName(s1);
goods.setGoodsLanguage(s2);
goods.setGoodsPrice(f);
goods.setGoodsCent(s5);
goods.setSortName(s6);
arraylist.add(goods);
count++;
if(count==16)
{
break;
}
}
stm.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
return arraylist;
}
//定义分页显示根据商品价格获得商品信息的方法
public Collection getGoodsByPrice(String s,int pageCount){
int a=s.indexOf("-");
float one=Float.parseFloat(s.substring(0,a));
float two=Float.parseFloat(s.substring(a+1));
GoodsClass goods;
ArrayList arraylist=new ArrayList();
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods where goodsPrice between "+one+" and "+two);
int count=0;
if(pageCount!=0){
resultset.absolute(pageCount*16);
}
while(resultset.next())
{
goods = new GoodsClass();
int i=resultset.getInt(1);
String s1=resultset.getString(2);
String s2=resultset.getString(3);
float f=resultset.getFloat(4);
String s5=resultset.getString(5);
String s6=resultset.getString(6);
goods.setGoodsId(i);
goods.setGoodsName(s1);
goods.setGoodsLanguage(s2);
goods.setGoodsPrice(f);
goods.setGoodsCent(s5);
goods.setSortName(s6);
arraylist.add(goods);
count++;
if(count==16)
{
break;
}
}
stm.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
return arraylist;
}
//定义根据商品ID获得商品信息的方法
public Collection getGoodsByGoodsId(String s){
int i1=Integer.parseInt(s);
GoodsClass goods;
ArrayList arraylist=new ArrayList();
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods where goodsId='"+i1+"'");
while(resultset.next())
{
goods = new GoodsClass();
int i=resultset.getInt(1);
String s1=resultset.getString(2);
String s2=resultset.getString(3);
float f=resultset.getFloat(4);
String s5=resultset.getString(5);
String s6=resultset.getString(6);
goods.setGoodsId(i);
goods.setGoodsName(s1);
goods.setGoodsLanguage(s2);
goods.setGoodsPrice(f);
goods.setGoodsCent(s5);
goods.setSortName(s6);
arraylist.add(goods);
}
stm.close();
con.close();
}catch(Exception e){
e.printStackTrace();
}
return arraylist;
}
//定义根据商品名称获得商品信息的方法
public Collection getGoodsByGoodsName(String s){
GoodsClass goods;
ArrayList arraylist=new ArrayList();
try{
Statement stm=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet resultset=stm.executeQuery("select * from Goods where goodsName like'%"+s+"%'");
while(resultset.next())
{
goods = new GoodsClass();
int i=resultset.getInt(1);
String s1=resultset.getString(2);
String s2=resultset.getString(3);
float f=resultset.getFloat(4);
String s5=resultset.getString(5);
String s6=resultset.getString(6);
goods.setGoodsId(i)
没有合适的资源?快使用搜索试试~ 我知道了~
JSP实现网上购物网站
共235个文件
gif:83个
jsp:79个
jpg:29个
4星 · 超过85%的资源 需积分: 10 182 下载量 94 浏览量
2010-05-23
00:53:29
上传
评论 4
收藏 989KB RAR 举报
温馨提示
JSP实现网上购物网站JSP实现网上购物网站JSP实现网上购物网站JSP实现网上购物网站JSP实现网上购物网站JSP实现网上购物网站
资源推荐
资源详情
资源评论
收起资源包目录
JSP实现网上购物网站 (235个子文件)
GoodsBean.class 10KB
Cart.class 6KB
UserBean.class 6KB
leavelanguageBean.class 5KB
messageBean.class 4KB
AdminBean.class 3KB
UserClass.class 2KB
SortBean.class 2KB
EncodingFilter.class 2KB
GoodsClass.class 2KB
LeaveLanguageClass.class 2KB
EncodingFilter.class 1KB
OrdersDetailsClass.class 1KB
OrdersClass.class 1KB
PageNumber.class 1KB
messageClass.class 1KB
AdminClass.class 961B
DBConnection.class 933B
SortClass.class 755B
.classpath 362B
message.gif 46KB
liucheng1.gif 42KB
liuy.gif 38KB
1.gif 26KB
1.gif 26KB
Admin_Login1.gif 25KB
cart04.gif 21KB
index.gif 15KB
index.gif 15KB
index.gif 15KB
index.gif 15KB
word.gif 13KB
Admin_Login2.gif 9KB
Admin_Login3.gif 7KB
cart1.gif 5KB
gouwuche.gif 5KB
jianzhi.gif 4KB
dingdan.gif 4KB
addjz.gif 4KB
liuyan.gif 4KB
Guser.gif 3KB
addorders.gif 3KB
addlanguage.gif 3KB
addSort.gif 3KB
user.gif 3KB
goods.gif 3KB
viewusers.gif 3KB
addGoods.gif 3KB
VGoods.gif 3KB
addusers.gif 3KB
logo_visa.gif 2KB
list_r1_c1.gif 2KB
cart01.gif 2KB
logo_cmb.gif 2KB
logo_abc.gif 1KB
T_contact.gif 1KB
T_contact.gif 1KB
T_contact.gif 1KB
T_favorite.gif 1KB
T_favorite.gif 1KB
T_favorite.gif 1KB
T_home.gif 1KB
T_home.gif 1KB
T_home.gif 1KB
daogou.gif 1KB
daogou.gif 1KB
logo_ccb.gif 1KB
logo_icbc.gif 1KB
list_r5_c1.gif 1KB
login_bt_zc.gif 1KB
login_bt_zc.gif 1KB
login_bt_zc.gif 1KB
login_bt_login.gif 1KB
login_bt_login.gif 1KB
login_bt_login.gif 1KB
daohan.gif 881B
daohan.gif 881B
daohan.gif 881B
gjcx.gif 402B
kscx.gif 402B
gjcx.gif 402B
kscx.gif 402B
kscx.gif 402B
detail.gif 295B
detail.gif 295B
top_my.gif 218B
top_my.gif 218B
top_my.gif 218B
top_dl.gif 214B
top_dl.gif 214B
top_dl.gif 214B
top_tc.gif 206B
top_tc.gif 206B
top_tc.gif 206B
guestbook_left_submit.gif 195B
top_help.gif 191B
top_help.gif 191B
top_help.gif 191B
guestbook_left_reset.gif 159B
list_r3_c1.gif 104B
共 235 条
- 1
- 2
- 3
wswifth
- 粉丝: 39
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页