package ajax.biz;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import ajax.db.DBUtils;
public class Product {
private String productId = null; //产品编号
private String productName = null; //产品名称
private double productPrice = 0; //产品价格
private int productsNum = 0; //产品数量
/**
* 通过产品ID构造一个产品
*/
public Product(String productId) {
String sql = "select pid, pname, price from products where pid = ?";
Connection conn = null; //声明Connection对象
PreparedStatement pstmt = null; //声明PreparedStatement对象
ResultSet rs = null; //声明ResultSet对象
try {
conn = DBUtils.getConnection(); //获取数据库连接
pstmt = conn.prepareStatement(sql); //根据sql创建PreparedStatement
pstmt.setString(1, productId); //设置参数
rs = pstmt.executeQuery(); //执行查询,返回结果集
if (rs.next()) {
this.productId = rs.getString(1);
this.productName = rs.getString(2);
this.productPrice = rs.getDouble(3);
this.productsNum = 1;
}
} catch (SQLException e) {
System.out.println(e.toString());
} finally {
DBUtils.close(rs); //关闭结果集
DBUtils.close(pstmt); //关闭PreparedStatement
DBUtils.close(conn); //关闭连接
}
}
//获取产品编号
public String getProductId() {
return productId;
}
//设置产品编号
public void setProductId(String productId) {
this.productId = productId;
}
//获取产品名称
public String getProductName() {
return productName;
}
//获取产品价格
public double getProductPrice() {
return productPrice;
}
//获取产品数量
public int getProductsNum() {
return productsNum;
}
//设置产品数量
public void setProductsNum(int productsNum) {
this.productsNum = productsNum;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Ajax相关教程及资料
共395个文件
jsp:118个
html:82个
js:54个
需积分: 0 9 下载量 55 浏览量
2009-07-16
09:18:37
上传
评论
收藏 10.54MB RAR 举报
温馨提示
自己收集的部分ajax的教程和源代码,希望对大家有用。
资源推荐
资源详情
资源评论
收起资源包目录
Ajax相关教程及资料 (395个子文件)
DBUtils.class 2KB
DBUtils.class 2KB
Product.class 2KB
Product.class 2KB
ShoppingCart.class 2KB
ShoppingCart.class 2KB
UploadListener.class 2KB
UploadListener.class 2KB
UploadInfo.class 1KB
UploadInfo.class 1KB
MonitoredDiskFileItemFactory.class 1KB
MonitoredDiskFileItemFactory.class 1KB
MonitoredOutputStream.class 1KB
MonitoredOutputStream.class 1KB
XMLUtils.class 1KB
XMLUtils.class 1KB
MonitoredDiskFileItem.class 1KB
MonitoredDiskFileItem.class 1KB
UploadMonitor.class 981B
UploadMonitor.class 981B
OutputStreamListener.class 237B
OutputStreamListener.class 237B
.classpath 538B
thickbox.css 3KB
thickbox.css 3KB
bbs.css 1KB
bbs.css 1KB
address.css 1KB
address.css 1KB
task.css 1KB
task.css 1KB
tree.css 613B
tree.css 613B
tree.css 463B
tree.css 463B
loadingAnimation.gif 7KB
loadingAnimation.gif 7KB
title.gif 3KB
title.gif 3KB
rating.gif 725B
rating.gif 725B
insert.gif 111B
insert.gif 111B
task.html 16KB
task.html 16KB
calendar.html 13KB
calendar.html 13KB
index.html 13KB
index.html 13KB
address.html 10KB
address.html 10KB
calc.html 8KB
calc.html 8KB
query_step.html 6KB
query_step.html 6KB
word_guess.html 6KB
word_guess.html 6KB
wishes.html 6KB
wishes.html 6KB
auto_login.html 5KB
auto_login.html 5KB
slideshow.html 5KB
slideshow.html 5KB
suggest.html 5KB
suggest.html 5KB
chatroom.html 5KB
chatroom.html 5KB
word_tip.html 5KB
word_tip.html 5KB
select_menu.html 5KB
select_menu.html 5KB
menu.html 5KB
menu.html 5KB
slider.html 4KB
slider.html 4KB
auto_save.html 4KB
auto_save.html 4KB
online_dict.html 4KB
online_dict.html 4KB
album.html 3KB
album.html 3KB
stock.html 3KB
stock.html 3KB
quick_search.html 3KB
quick_search.html 3KB
read_rss.html 3KB
read_rss.html 3KB
server_test.html 3KB
server_test.html 3KB
tab_page.html 3KB
tab_page.html 3KB
read_source.html 3KB
read_source.html 3KB
thickbox.html 3KB
thickbox.html 3KB
register.html 2KB
register.html 2KB
postalcode.html 2KB
postalcode.html 2KB
mail_list.html 2KB
共 395 条
- 1
- 2
- 3
- 4
资源评论
xy49023771
- 粉丝: 7
- 资源: 114
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功