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

📄 context.java

📁 简易通用Blog
💻 JAVA
字号:
package org.adam.bean;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.util.Vector;

import org.db.DB;
public class Context {
	private int context_id;
	private int blog_id;
	private int sort_id;
	private String title;
	private String context;
	private String pubtime;
	private String sortname;
	public int getBlog_id() {
		return blog_id;
	}
	public void setBlog_id(int blog_id) {
		this.blog_id = blog_id;
	}
	public String getContext() {
		return context;
	}
	public void setContext(String context) {
		this.context = context;
	}
	public int getContext_id() {
		return context_id;
	}
	public void setContext_id(int context_id) {
		this.context_id = context_id;
	}
	public String getPubtime() {
		return pubtime;
	}
	public void setPubtime(String pubtime) {
		this.pubtime = pubtime;
	}
	public int getSort_id() {
		return sort_id;
	}
	public void setSort_id(int sort_id) {
		this.sort_id = sort_id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public static Vector getAllContext(DB db,int blogid){
		Context context;
		Vector v=new Vector();
		String sql="select* from context,sort where context.sort_id=sort.sort_id and context.blog_id="+blogid;
		//System.out.println(sql);
		try{
			ResultSet rs=db.getData(sql);
			while(rs.next()){
				context=new Context();
				context.setBlog_id(rs.getInt("blog_id"));
				context.setContext(rs.getString("context"));
				context.setContext_id(rs.getInt("context_id"));
				context.setPubtime(rs.getString("pubtime"));
				context.setSort_id(rs.getInt("sort_id"));
				context.setTitle(rs.getString("title"));
				context.setSortname(rs.getString("sortname"));
				v.add(context);
			}
			db.closed();
			return v;
		}catch(Exception e){
			return null;
		}
	}
	public static Vector getContext(DB db,int context_id){
		Context context;
		Vector v=new Vector();
		String sql="select * from context where context_id="+context_id;
		try{
			ResultSet rs=db.getData(sql);
			while(rs.next()){
				context=new Context();
				context.setBlog_id(rs.getInt("blog_id"));
				context.setContext(rs.getString("context"));
				context.setContext_id(rs.getInt("context_id"));
				context.setPubtime(rs.getString("pubtime"));
				context.setSort_id(rs.getInt("sort_id"));
				context.setTitle(rs.getString("title"));
				v.add(context);
			}
			db.closed();
			return v;
		}catch(Exception e){
			return null;
		}
	}
	public String getSortname() {
		return sortname;
	}
	public void setSortname(String sortname) {
		this.sortname = sortname;
	}
	public void WriteBlog(DB db){
		String sql="insert into context(blog_id,sort_id,title,context,pubtime) values("+blog_id+","+sort_id+",'"+title+"','"+context+"','"+pubtime+"')";
		System.out.println(sql);
		db.Insert(sql);
		db.closed();
	}
	public static Vector getSorts(DB db,int blog_id){
		//Context c;
		Vector v1=new Vector();
		String sql="select * from sort where blog_id="+blog_id;
		
			ResultSet rs=db.getData(sql);
			try {
				while(rs.next()){
					Context c=new Context();
					//c.setBlog_id(rs.getInt("blog_id"));
					c.setSort_id(rs.getInt("sort_id"));
					c.setSortname(rs.getString("sortname"));
					v1.add(c);
				}
				db.closed();
				return v1;
			} catch (SQLException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
				return null;
			}
			
		
	}
}

⌨️ 快捷键说明

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