java企业电子商城_jsp+servlet开发java web诚欣企业电子商城(源码+数据库脚本)

package com.wy.dao;

import com.wy.tool.JDBConnection;

import java.sql.*;

import java.util.*;

import com.wy.domain.BigTypeForm;

//对商品大类别信息的操作

public class BigTypeDao {

private Connection connection = null; //定义连接的对象

private PreparedStatement ps = null; //定义预准备的对象

private JDBConnection jdbc = null; //定义数据库连接对象

public BigTypeDao() {

jdbc = new JDBConnection();

connection = jdbc.connection; //利用构造方法取得数据库连接

}

//以数据库流水号为条件查询大类别的名称

public String selectName(Integer id) {

String name = null;

try {

this.ps = connection.prepareStatement("select * from tb_bigType where id=?");

ps.setString(1, id.toString());

ResultSet rs = ps.executeQuery();

while (rs.next()) {

name = rs.getString("bigName");

}

}

catch (SQLException ex) {

ex.printStackTrace();

}

return name;

}

//删除操作

public boolean deleteBig(Integer id) {

try {

ps = connection.prepareStatement("delete from tb_bigType where id=?");

ps.setString(1, id.toString());

ps.executeUpdate();

ps.close();

return true;

}

catch (SQLException ex) {

ex.printStackTrace();

return false;

}

}

//添加操作

public void insertBig(String name) {

try {

ps = connection.prepareStatement("insert into tb_bigType values (null,?,now())");

ps.setString(1, name);

ps.executeUpdate();

ps.close();

}

catch (SQLException ex) {

ex.printStackTrace();

}

}

//全部查询的操作

public List selectBig() {

List list = new ArrayList();

BigTypeForm big = null;

try {

this.ps = connection.prepareStatement("select * from tb_bigType order by id DESC");

ResultSet rs = ps.executeQuery();

while (rs.next()) {

big = new BigTypeForm();

big.setId(Integer.valueOf(rs.getString(1)));

big.setBigName(rs.getString(2));

big.setCreaTime(rs.getString(3));

list.add(big);

}

}

catch (SQLException ex) {

ex.printStackTrace();

}

return list;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值