首页>代码>JSP Servlet开发博客天空源代码下载>/博客天空/blog/src/com/wy/dao/ArticleTypeDao.java
package com.wy.dao;

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

import com.wy.form.ArticleTypeForm;
import com.wy.tool.JDBConnection;

public class ArticleTypeDao {
	private JDBConnection connection = null;

	public ArticleTypeDao() {
		connection = new JDBConnection();
	}

	public boolean operationArticleType(String operation, ArticleTypeForm form) {
		boolean flag = false;
		String sql = null;
		if (operation.equals("添加"))
			sql = "insert into tb_articleType values ("+(int)Math.random()*99999999+",'" + form.getTypeName()
					+ "','" + form.getDescription() + "')";
		if (operation.equals("删除"))
			sql = "delete from tb_articleType where id='" + form.getId() + "'";
		if (connection.executeUpdate(sql)) {
			flag = true;
		}
		return flag;
	}

	
	
	public String queryArticleTypeName(Integer id) {
		String typeName = null;
		String sql = "select * from tb_articleType where id='" + id + "'";
		ResultSet rs = connection.executeQuery(sql);
		try {
			while (rs.next()) {
				typeName = rs.getString("typeName");
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return typeName;
	}

	public List queryArticleType() {
		List list = new ArrayList();
		ArticleTypeForm form = null;
		String sql = "select * from tb_articleType";
		ResultSet rs = connection.executeQuery(sql);
		try {
			while (rs.next()) {
				form = new ArticleTypeForm();
				form.setId(rs.getInt(1));
				form.setTypeName(rs.getString(2));
				form.setDescription(rs.getString(3));
				list.add(form);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

}
最近下载更多
ma406805131  LV19 2024年12月19日
hulewang  LV8 2024年10月12日
无名氏111  LV33 2024年6月24日
sz1111111  LV2 2024年3月26日
寒江雪2017  LV10 2024年1月23日
李朝磊  LV18 2024年1月6日
pangzhihui  LV14 2023年12月27日
wanglongfei2  LV2 2023年6月15日
13133117021  LV5 2023年5月31日
ewan007  LV30 2023年3月13日
最近浏览更多
ma406805131  LV19 2024年12月19日
lyh1989  LV34 2024年12月11日
hulewang  LV8 2024年10月12日
yellow_flowers  LV8 2024年7月9日
无名氏111  LV33 2024年6月24日
sz1111111  LV2 2024年3月26日
寒江雪2017  LV10 2024年1月23日
duoduo1234  LV2 2024年1月15日
taoshen95  LV16 2024年1月11日
wttttts  LV2 2024年1月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友