亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? dboperate.java

?? ajax+jsp打造的blog.學(xué)習(xí)ajax項目的絕好源碼
?? JAVA
字號:
package cn.com.blogonline;

import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

public class DbOperate {

	/**
	 * 根據(jù)用戶名得到Blog對象
	 */
	public Blog getBlog(String userId) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		Blog blog = null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Blog where username=:userId");
			query.setParameter("userId", userId);
			List list = query.list();
			if (!list.isEmpty())
				blog = (Blog) list.get(0);
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		session.close();
		return blog;
	}

	/**
	 * 根據(jù)ID得到Blog對象
	 */
	public Blog getBlog(int Id) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		Blog blog = null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Blog where id=" + Id);
			List list = query.list();
			if (!list.isEmpty())
				blog = (Blog) list.get(0);
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		session.close();
		return blog;
	}


	/**
	 * 得到熱點Blog對象集
	 */
	public List getBlogs(int showCount) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Blog order by visitcount desc");
			if (showCount>0){
				query.setMaxResults(showCount);								//記錄集最大個數(shù)
			}
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到匹配Blog對象集
	 */
	public List getMatchBlogs(String key) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Blog where subject like '%" + key + "%'");
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 根據(jù)ID得到Sort對象
	 */
	public Sort getSort(int Id) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		Sort sort = null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Sort where id=" + Id);
			List list = query.list();
			if (!list.isEmpty())
				sort = (Sort) list.get(0);
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		session.close();
		return sort;
	}

	/**
	 * 根據(jù)ID得到Links對象
	 */
	public Links getLink(int Id) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		Links link = null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Links where id=" + Id);
			List list = query.list();
			if (!list.isEmpty())
				link = (Links) list.get(0);
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		session.close();
		return link;
	}

	/**
	 * 得到指定文章對象
	 */
	public Article getArticle(int articleid) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		Article article = null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
		//	創(chuàng)建查詢對象
			Query query = session.createQuery("from Article where id=" + articleid);
			List list = query.list();
			if (!list.isEmpty())
				article = (Article) list.get(0);
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		session.close();
		return article;
	}

	/**
	 * 得到匹配Article對象集
	 */
	public List getMatchArticles(String key) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Article where title like '%" + key + "%'");
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到最新文章對象集
	 */
	public List getArticles(int showCount) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			Query query = session.createQuery("from Article order by pubtime desc");
			if (showCount>0){
				query.setMaxResults(showCount);								//記錄集最大個數(shù)
			}
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到指定博客最新文章對象集
	 */
	public List getBlogArticles(int blogid,int sortid) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			String strSql = "from Article  where blogid=" + blogid;//創(chuàng)建一個查詢語句,查詢指定類別產(chǎn)品;
			if (sortid>0){
				strSql = strSql + " and sortid=" + sortid ;								//記錄集最大個數(shù)
			}
			strSql = strSql + " order by pubtime desc" ;								//記錄集最大個數(shù)
			Query query = session.createQuery(strSql);
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到指定博客文章分類對象集
	 */
	public List getBlogSorts(int blogid) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			String strSql = "from Sort where blogid=" + blogid;//創(chuàng)建一個查詢語句,查詢指定類別產(chǎn)品;
			Query query = session.createQuery(strSql);
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到指定博客超級鏈接對象集
	 */
	public List getBlogLinks(int blogid) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			String strSql = "from Links where blogid=" + blogid;//創(chuàng)建一個查詢語句,查詢指定類別產(chǎn)品;
			Query query = session.createQuery(strSql);
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 得到指定文章回復(fù)對象集
	 */
	public List getFeedBacks(int articleid) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		List list=null;
		Transaction tx = null;
		try {
			tx = session.beginTransaction();
//			創(chuàng)建查詢對象
			String strSql = "from FeedBack  where articleid=" + articleid
						+ " order by pubtime desc" ;					//創(chuàng)建一個查詢語句,查詢指定類別產(chǎn)品;			
			Query query = session.createQuery(strSql);
			list = query.list(); //從數(shù)據(jù)庫取出數(shù)據(jù),并自動封裝到List集合中
			tx.commit();
		} catch (HibernateException e) {
			if (tx != null)
				tx.rollback();
			throw e;
		}
		HibernateUtil.closeSession();
		return list; 
	}

	/**
	 * 插入實體對象所對應(yīng)的記錄
	 */
	public void save(Object obj) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		if (obj != null) {
			Transaction tx = null;
			try {
				tx = session.beginTransaction();
				session.save(obj);
				tx.commit();
			} catch (HibernateException e) {
				if (tx != null)
						tx.rollback();
				throw e;
			}
		}
		session.close();
	}

	/**
	 * 修改實體對象所對應(yīng)的記錄
	 */
	public void update(Object obj) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		
		if (obj != null) {
			Transaction tx = null;
			try {
				tx = session.beginTransaction();
				session.update(obj);
				tx.commit();
			} catch (HibernateException e) {
				if (tx != null)
						tx.rollback();
				throw e;
			}
		}
		session.close();
	}
	
	/**
	 * 刪除對象所對應(yīng)的記錄
	 */
	public void delete(Object obj) throws HibernateException {
		Session session = HibernateUtil.currentSession();
		if (obj != null) {
			Transaction tx = null;
			try {
				tx = session.beginTransaction();
				session.delete(obj);
				tx.commit();
			} catch (HibernateException e) {
				if (tx != null)
						tx.rollback();
				throw e;
			}
		}
		session.close();
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品66部| 91国内精品野花午夜精品| 欧美成人激情免费网| 中文字幕欧美国产| 国产综合色在线| 日本一区二区三区久久久久久久久不 | 色激情天天射综合网| 日韩码欧中文字| 欧美伦理影视网| 国产一区二区成人久久免费影院| 国产三级欧美三级日产三级99| 久久99热国产| 精品国产乱码久久久久久老虎| 久久成人免费网| 日韩欧美www| 国产成人av电影在线| 26uuu成人网一区二区三区| 国产精品家庭影院| 成人免费看片app下载| 亚洲色图另类专区| 91.com视频| 国产精品亚洲综合一区在线观看| 色综合天天在线| 午夜精品影院在线观看| 精品日韩99亚洲| 色播五月激情综合网| 男人的天堂亚洲一区| 国产精品福利一区二区三区| 欧美精品亚洲二区| 亚洲三级视频在线观看| 欧美一卡二卡三卡| 91丝袜美腿高跟国产极品老师| 国产一区二区中文字幕| 成人黄色国产精品网站大全在线免费观看| 成人app下载| 麻豆一区二区三| 久久不见久久见免费视频1| 久久99国产精品尤物| 久久精品99国产国产精| 日韩亚洲欧美一区二区三区| 日韩和的一区二区| 国产精品全国免费观看高清| 欧美在线三级电影| 国产一区视频网站| 亚洲午夜在线电影| 久久久久99精品国产片| 老司机午夜精品| 91精品国产综合久久精品 | 中国av一区二区三区| 色哦色哦哦色天天综合| 国内不卡的二区三区中文字幕| 国产精品福利一区| 欧美美女网站色| 欧美自拍丝袜亚洲| proumb性欧美在线观看| 国产精品污网站| 国产日韩精品一区二区浪潮av| 国产欧美日韩视频在线观看| 国产三级三级三级精品8ⅰ区| 91精品国产一区二区三区蜜臀| 欧美一卡二卡三卡| 久久精品欧美日韩| 久久色视频免费观看| 精品成人一区二区三区| 国产日韩欧美激情| 国产精品久久午夜| 日本乱人伦aⅴ精品| 欧美三级电影精品| 精品国产自在久精品国产| 欧美成人综合网站| 综合欧美一区二区三区| 亚洲一区二区三区四区五区黄| 午夜精品久久久久影视| 国产精选一区二区三区| 国产精品成人在线观看| 污片在线观看一区二区| 高清国产一区二区| 亚洲欧洲国产日本综合| 国产欧美日韩久久| 久久久蜜桃精品| 久久9热精品视频| 亚洲另类在线一区| 日韩电影在线观看网站| 91麻豆精品国产91久久久使用方法| 国产精品每日更新在线播放网址| 日本欧美在线观看| 欧洲在线/亚洲| 精品国产三级电影在线观看| 日本不卡在线视频| 午夜不卡在线视频| 在线国产亚洲欧美| 国产精品无码永久免费888| 精品视频免费在线| 免费欧美在线视频| 国产亚洲精品超碰| 蜜臀av性久久久久蜜臀aⅴ流畅| 欧美在线|欧美| 色综合天天综合色综合av| 欧美激情一区二区| 久久精品综合网| 亚洲一区中文日韩| 91啪亚洲精品| 一区二区日韩电影| 欧美日韩免费一区二区三区视频| 一区二区三区中文字幕在线观看| 国产精品1区2区3区在线观看| 欧美电视剧在线观看完整版| 成人国产电影网| 日本久久一区二区| 亚洲一二三四区不卡| 欧美喷潮久久久xxxxx| 天堂精品中文字幕在线| 色欧美88888久久久久久影院| 亚洲一区在线播放| 日韩欧美国产wwwww| 国产一区在线观看视频| 亚洲免费高清视频在线| 精品国产人成亚洲区| 在线观看中文字幕不卡| 国产激情偷乱视频一区二区三区| 日本va欧美va精品发布| 欧美精品一区二区蜜臀亚洲| 一本大道久久a久久精品综合| 久久99精品国产91久久来源| 亚洲第一成人在线| 热久久国产精品| 日本一区二区动态图| 欧美丰满少妇xxxxx高潮对白| av中文字幕不卡| 成人福利视频在线| 精品一区二区三区在线播放| 亚洲在线视频网站| 中文字幕乱码亚洲精品一区| 久久美女艺术照精彩视频福利播放| 欧美美女一区二区| 欧美精品一二三四| 欧美精品电影在线播放| 欧美精品在线观看一区二区| 欧美最新大片在线看| 欧美伊人久久久久久久久影院| 99re这里都是精品| 在线观看三级视频欧美| 日本午夜精品视频在线观看| 亚洲小少妇裸体bbw| 婷婷久久综合九色综合绿巨人| 日本一不卡视频| 加勒比av一区二区| 91在线精品一区二区| 丁香激情综合国产| av在线不卡网| 欧美日韩一本到| 日韩欧美你懂的| 悠悠色在线精品| 亚洲风情在线资源站| 蜜桃精品视频在线| 99久久99久久精品免费观看| 欧美日韩中文字幕精品| 日韩精品在线一区| 国产精品久久久久久久午夜片| 亚洲免费观看高清在线观看| 亚洲成人在线免费| 国产一区二区在线免费观看| 波多野结衣在线一区| 欧美久久高跟鞋激| 亚洲同性gay激情无套| 日韩制服丝袜av| 成人免费小视频| 日本高清无吗v一区| 亚洲成人自拍一区| 99精品欧美一区二区三区小说| 制服丝袜成人动漫| 亚洲精品视频一区二区| 国产精品69毛片高清亚洲| 欧美人牲a欧美精品| ...xxx性欧美| 成人性生交大合| 欧美性xxxxxx少妇| 亚洲色图都市小说| 国产剧情在线观看一区二区 | 精品乱码亚洲一区二区不卡| 亚洲电影激情视频网站| 色屁屁一区二区| 国产精品全国免费观看高清| 国产一区不卡在线| 亚洲精品一区二区三区99| 蜜臀av性久久久久蜜臀aⅴ四虎| 在线观看视频一区二区| 亚洲日本免费电影| 色94色欧美sute亚洲线路一ni | 中文字幕av不卡| 东方aⅴ免费观看久久av| 国产欧美一区二区精品性色超碰 | 精品88久久久久88久久久| 99精品在线免费| 国产日韩av一区| 99精品视频一区二区三区| 一区二区三区在线播放| 777奇米四色成人影色区| 日韩电影一区二区三区| 在线91免费看|