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

📄 note.java

📁 基于struts的employee
💻 JAVA
字号:
package StudyNote;

import java.util.*;
import java.sql.ResultSet;

public class Note{
	
	protected int id;
	protected String title ;
	protected String content;
	protected String talker;
	protected String time;
	
	public Note(){	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public void setTitle(String title) {
		this.title = title;
	}
	
	public void setContent(String content) {
		this.content = content;	
	}
	
	public void setTalker(String talker) {
		this.talker = talker;
	}
	
	public void setTime(String time) {
		this.time = time;
	}
	
	public int getId(){
		return id;
	}	
	
	public String getTitle(){
		return title;
	}
		
	public String getContent(){
		return content;
	}	
		
	public String getTalker(){
		return talker;
	}	
		
	public String getTime(){
		return time;
	}	
	
	public boolean Insert(DB db) throws Exception{
        String strSql;
		ResultSet rs;
		int iMaxId;
        strSql = "Select max(id) From note";
		rs = db.OpenSql(strSql);  
		if ( rs.next()) {
			iMaxId=rs.getInt(1)+1;
		}
		else{
			iMaxId=1;
		}
        
        strSql = "insert into note values(" 
        		+ iMaxId 	+",'"
				+ title 	+"','"
				+ content 	+"','"
				+ talker 	+"',sysdate)";
		if ( db.ExecSql(strSql)==0) {
			return false;
		}
		else{
			return true;
		}
	
	}
	
	public static int GetNoteCount(DB db) throws Exception{
		ResultSet rs,rsNest;
        String strSql=null;
        int iRecordCount=0;
		
        strSql = "select count(*) from note ";
		rs = db.OpenSql(strSql);  
		if ( rs.next()) {
			iRecordCount=rs.getInt(1);
		}
		return iRecordCount;
	}
		
	public static Vector SearchNoteTitle(DB db,int pageId) throws Exception{
		Vector noteList = new Vector();
		ResultSet rs,rsNest;
        String strSql=null;
//        int iRecordCount=0;
        int iCurRecord=0;
		
        strSql = "select * from note order by time desc";
		rs = db.OpenSql(strSql);
		

		int iCount=0;
		iCurRecord=pageId * Constants.NOTE_PAGE_SIZE + 1;          
		rs.absolute(iCurRecord);	
		do{
			Note note = new Note();
			
			note.setId(rs.getInt("id")) ;
			note.setTitle(rs.getString("title")) ;
			note.setTime(rs.getString("time")) ;
			note.setTalker(rs.getString("talker")) ;
			
			noteList.add(note);
			iCount++;
			if (iCount>=Constants.NOTE_PAGE_SIZE){
				break;
			}
		}while(rs.next());
					
		System.out.println("noteList:        "+noteList.size());
					
		return noteList;
	}
	
	
	public static Note GetDetail(DB db,int noteId) throws Exception{
		Vector noteList = new Vector();
		ResultSet rs,rsNest;
        String strSql=null;
        String rplContent=null;
		
        strSql = "select * from note where id = " + noteId ;
		rs = db.OpenSql(strSql);
		Note note = new Note();
		if (rs.next()){
			
			note.setId(noteId) ;
			note.setTitle(rs.getString("title")) ;
		
			rplContent = rs.getString("content");
			rplContent = rplContent.replaceAll("\n","<br>");
			note.setContent(rplContent) ;
		}
		return note;
	}
	
}

⌨️ 快捷键说明

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