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

📄 articleeditdao.java

📁 实现银行系统中某个部门的计算机设备管理、公共信息管理、权限用户管理、系统设置等,为系统的安全正常运行提供保障
💻 JAVA
字号:
package com.isoftstone.banktearm1.dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.TreeMap;

import com.isoftstone.banktearm1.db.DB;
import com.isoftstone.banktearm1.vo.BankTeam1ArticleVo;

public class ArticleEditDao extends DB{
	   
	BankTeam1ArticleVo bankteamarticlevo=new BankTeam1ArticleVo();
	
	public void search(String authorID,String authorName,String artTitle,String usetime1,String usetime2) throws SQLException, ClassNotFoundException{
		String str="select * from article where 1=1";
			if(!authorID.equals(""))
	str=str+" and author_id='"+authorID+"'";
	if(!authorName.equals(""))
		str=str+" and author_name='"+authorName+"'";
	if(!artTitle.equals(""))
		str=str+" and art_title='"+artTitle+"'";
	if(!usetime1.equals("")&&!usetime2.equals(""))
	{
		str=str+" and deliver_time>'"+usetime1+"' and deliver_time<'"+usetime2+"'";
	}
		 
		PreparedStatement pstmt = getConnection().prepareStatement(str);
		
	}
	
	public TreeMap searchArticle(String ArticleName)throws SQLException, ClassNotFoundException{
		PreparedStatement pstmt;
		TreeMap map=new TreeMap();
		pstmt=getConnection().prepareStatement("select * from article where author_name=?");
		pstmt.setString(1, ArticleName);
		ResultSet rs=pstmt.executeQuery();
		BankTeam1ArticleVo articlevo=null;
		Integer i=1;
		while(rs.next())
		
			{articlevo=new BankTeam1ArticleVo(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8));
			map.put(new Integer(i), articlevo);
			i++;			
			}
			
		
			return map;
		
	}
//	public static void main(String args[]){
//		ArticleEditDao t=new ArticleEditDao();
//		TreeMap mm=null;
//		BankTeam1ArticleVo ttt=new BankTeam1ArticleVo();
//		try {
//			mm= t.searchArticle("扶绥大");
//		} catch (SQLException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		} catch (ClassNotFoundException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		Integer n=mm.size();
//		ttt=(BankTeam1ArticleVo)mm.get(n-1);
//		System.out.println(n);
//		System.out.println(ttt.getAuthor_id());
//		
//		
//		
//	}
	
	
	public BankTeam1ArticleVo getArticle(BankTeam1ArticleVo articlevo)throws SQLException, ClassNotFoundException{
		//int id=bankteamarticlevo.getArt_id();
		PreparedStatement pstmt;
		pstmt=getConnection().prepareStatement("select * from article");
		ResultSet rs=pstmt.executeQuery();
		BankTeam1ArticleVo articlevo1=null;
		ArrayList list=new ArrayList();
		while(rs.next()){
			articlevo1=new BankTeam1ArticleVo(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6),rs.getString(7),rs.getString(8));
			list.add(articlevo1);
		}
		closs(rs, pstmt, getConnection());
		return articlevo;
	}
	
	public void updateArticle(BankTeam1ArticleVo articlevo)throws SQLException, ClassNotFoundException{
		
		PreparedStatement pstmt=getConnection().prepareStatement("update article set art_title=?,art_title2=?,art_abstract=?,author_id=?,author_name=?,deliver_time=?,art_content=? where art_id=?");
		pstmt.setString(1,articlevo.getArt_title());
    	pstmt.setString(2,articlevo.getArt_title2());
    	pstmt.setString(3,articlevo.getArt_abstract());
    	pstmt.setString(4,articlevo.getAuthor_id());
    	pstmt.setString(5,articlevo.getAuthor_name());
    	pstmt.setString(6,articlevo.getDeliver_time());
    	pstmt.setString(7,articlevo.getArt_content());
    	pstmt.setInt(8,articlevo.getArt_id());
    	pstmt.executeUpdate();
    	super.closs(pstmt, getConnection());
		}
	
     public void deleteArticle(int id)throws SQLException, ClassNotFoundException{
    	 PreparedStatement pstmt=getConnection().prepareStatement("delete from article where art_id=?");
 		pstmt.setInt(1,id);
 		pstmt.executeUpdate();
    	 closs(pstmt,getConnection());
     }
	

}

⌨️ 快捷键说明

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