📄 articleeditdao.java
字号:
package com.isoftstone.banktearm1.dao;
/*
* 03作成,文章编辑
*/
import java.sql.*;
import java.util.*;
import java.util.TreeMap;
import javax.swing.text.html.HTMLDocument.Iterator;
import com.isoftstone.banktearm1.db.DB;
import com.isoftstone.banktearm1.vo.BankTeam1ArticleVo;
public class ArticleEditDao extends DB{
public ArrayList search(String authorID,String authorName,String artTitle,String usetime1,String usetime2) throws SQLException, ClassNotFoundException{
ArrayList mylist=new ArrayList();
Connection cn=this.getConnection();
Statement st=cn.createStatement();
ResultSet rs=null;
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(""))
{
str=str+" and deliver_time>'"+usetime1+"'";
}
if(!usetime2.equals(""))
{
str=str+" and deliver_time<'"+usetime2+"'";
}
rs=st.executeQuery(str);
while(rs.next()){
BankTeam1ArticleVo myvo=new BankTeam1ArticleVo();
myvo.setArt_id(rs.getInt(1));
myvo.setArt_title(rs.getString(2));
myvo.setArt_title2(rs.getString(3));
myvo.setArt_abstract(rs.getString(4));
myvo.setAuthor_id(rs.getString(5));
myvo.setAuthor_name(rs.getString(6));
myvo.setDeliver_time(rs.getString(7));
myvo.setArt_content(rs.getString(8));
mylist.add(myvo);
}
this.closs(rs, st, cn);
return mylist;
}
public ArrayList searchTop5() throws SQLException, ClassNotFoundException{
ArrayList mylist=new ArrayList();
Connection cn=this.getConnection();
Statement st=cn.createStatement();
ResultSet rs=null;
String str="select Top 5 * from article order by deliver_time desc";
rs=st.executeQuery(str);
while(rs.next()){
BankTeam1ArticleVo myvo=new BankTeam1ArticleVo();
myvo.setArt_id(rs.getInt(1));
myvo.setArt_title(rs.getString(2));
myvo.setArt_title2(rs.getString(3));
myvo.setArt_abstract(rs.getString(4));
myvo.setAuthor_id(rs.getString(5));
myvo.setAuthor_name(rs.getString(6));
myvo.setDeliver_time(rs.getString(7));
myvo.setArt_content(rs.getString(8));
mylist.add(myvo);
}
this.closs(rs, st, cn);
return mylist;
}
public BankTeam1ArticleVo search(String art_id) throws SQLException, ClassNotFoundException{
BankTeam1ArticleVo myvo=new BankTeam1ArticleVo();
ArrayList mylist=new ArrayList();
Connection cn=this.getConnection();
Statement st=cn.createStatement();
ResultSet rs=null;
String str="select * from article where 1=1";
str=str+" and art_id="+Integer.parseInt(art_id);
rs=st.executeQuery(str);
rs.next();
myvo.setArt_id(rs.getInt(1));
myvo.setArt_title(rs.getString(2));
myvo.setArt_title2(rs.getString(3));
myvo.setArt_abstract(rs.getString(4));
myvo.setAuthor_id(rs.getString(5));
myvo.setAuthor_name(rs.getString(6));
myvo.setDeliver_time(rs.getString(7));
myvo.setArt_content(rs.getString(8));
this.closs(rs, st, cn);
return myvo;
}
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 + -