⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 photoinfodao.java

📁 一个仿造淘宝的jsp网站。功能比较完善
💻 JAVA
字号:
package com.jc.taobao.gjj.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.jc.taobao.gjj.db.DBManager;
import com.jc.taobao.gjj.entity.PhotoInfo;

public class PhotoInfoDAO{
	DBManager dm = new DBManager();

	public int delete(Integer id) {
		String sql = "delete from photoinfo where photoid=" + id;
		return dm.updb(sql);
	}

	public int merge(PhotoInfo pi) {
		String sql = "update photoinfo set photopath='" + pi.getPhotopath()
				+ "' where photoid=" + pi.getPhotoid();
		return dm.updb(sql);
	}

	public int save(PhotoInfo pi) {
		String sql = "insert into photoinfo values('" 
				+ pi.getPhotopath() + "')";
		return dm.updb(sql);
	}
	
	private List<PhotoInfo> query(String sql)//查询
	{
		List<PhotoInfo> list = new ArrayList<PhotoInfo>();
		ResultSet rs = dm.getRs(sql);
		try {
			while(rs.next())
			{
				PhotoInfo photo = new PhotoInfo();
				photo.setPhotoid(rs.getInt("photoid"));
				photo.setPhotopath(rs.getString("photopath"));
				list.add(photo);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return list;
	}
	
	public List<PhotoInfo> querybyALL()//查询所有图片信息
	{
		String sql="select * from photoinfo";
		return query(sql);
	}
	
	public List<PhotoInfo> queryAllLuntanBiaoQingPic()//查询所有论坛表情图片
	{
		String sql="select * from photoinfo where photopath like 'image/taobaoluntan/em%'";
		return query(sql);
	}
	
	public List<PhotoInfo> queryAllFacePic()//查询所有的用户图像表情
	{
		String sql="select * from photoinfo where photopath like 'image/face/%'";
		return query(sql);
	}
	
	public List<PhotoInfo> querybyphotoid(Integer pid)//根据图片编号查图片路径
	{
		String sql="select * from photoinfo where photoid="+pid;
		return query(sql);
	}
	public List<PhotoInfo> querybyphotopath(String photopath)//根据图片编号查图片路径
	{
		String sql="select * from photoinfo where photopath='"+photopath+"'";
		return query(sql);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -