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

📄 newstypedaoimpl.java~5~

📁 明日新闻网络中心是由吉林省明日科技有限公司开发的一个信息管理系统
💻 JAVA~5~
字号:
package com.victor.dao;

import java.util.List;
import java.util.ArrayList;
import com.victor.tool.JDBConnection;
import java.sql.ResultSet;
import java.sql.*;
import com.victor.domain.NewsTypeActionForm;

public class NewsTypeDaoImpl
    implements NewsTypeDao {
//查看所有的类别的方法
  public List typeWarch() {
    NewsTypeActionForm newsType = null;
    List list = new ArrayList();
    JDBConnection connection = new JDBConnection();
    String sql = "select * from tb_newsType";
    ResultSet rs = connection.executeQuery(sql);
    try {
      while (rs.next()) {
        newsType = new NewsTypeActionForm();
        newsType.setTypeID(Integer.valueOf(rs.getString(1)));
        newsType.setTypeName(rs.getString(2));
        newsType.setTypeTime(rs.getString(3));
        list.add(newsType);
      }
    }
    catch (SQLException ex) {
    }
    connection.close();
    return list;
  }

//对新闻类别的增加
  public void insertTpye(NewsTypeActionForm typeForm) {
    JDBConnection connection = new JDBConnection();
    String sql = "insert into tb_newsType values('" + typeForm.getTypeName() +
        "',getDate())";
    connection.executeUpdate(sql);
    connection.close();

  }

//对新闻类别的删除
  public void deleteType(NewsTypeActionForm typeForm) {
    JDBConnection connection = new JDBConnection();
    String sql = "delete from tb_newsType where ID='" + typeForm.getTypeID() +
        "'";
    connection.executeUpdate(sql);
    connection.close();
  }

//修改新闻的之前先要查出来原来的名称显示到下一页
  public String selectOneTpye(NewsTypeActionForm typeForm) {
    NewsTypeActionForm newsTypeActionForm = null;
    String typename = "";
    JDBConnection connection = new JDBConnection();
    String sql = "select * from tb_newsType where ID='" + typeForm.getTypeID() +
        "'";
    ResultSet rs = connection.executeQuery(sql);
    try {
      while (rs.next()) {
        newsTypeActionForm = new NewsTypeActionForm();
        newsTypeActionForm.setTypeName(rs.getString(2));
        typename = rs.getString(2);
      }
    }
    catch (SQLException ex) {
    }
    connection.close();
    return typename;
  }
}

⌨️ 快捷键说明

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