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

📄 userlist_imp.java

📁 struts2 dwr spring 集成的例子
💻 JAVA
字号:
package Com.Fjzy.Dao.User.Imp;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.sun.java_cup.internal.internal_error;

import Com.Fjzy.Dao.User.UsetList_dao;
import Com.Fjzy.Model.User.UserList;

	public class UserList_Imp extends HibernateDaoSupport implements UsetList_dao {
		
		private Transaction tran;
			
		public UserList_Imp(){
			
		}
		
		public String Login(String name, String pwd){
			List list = new ArrayList();
			list = Select("1", "name='"+ name +"' and pwd='"+ pwd + "'");
			if(list.size() > 0){
				return "ok";
			}
			return "error";
		}
		
		/**
		 * 查询记录
		 * @return 记录集
		 */
		public List Select(String top,String where){
			List list = new ArrayList();
			HibernateTemplate ht = this.getHibernateTemplate();
			list = ht.find("from UserList where "+ where);
//			Session session = this.getSession();
//			Query query = session.getNamedQuery("Proc_Search");
//			query.setString(0,top);
//			query.setString(1,where);
//			list = query.list();
			return list;
		}
	//	
//		/**
//		 * 取出用户名对象
//		 * @param id
//		 * @return
//		 */
		public UserList Get(int id){
			UserList model = new UserList();
			model = (UserList)this.getHibernateTemplate().get(UserList.class,id);
			return model;
		}
	//	
//		/**
//		 * 更新
//		 * @param model
//		 * @return
//		 */
//		public int Updata(UserList model){
//			
//			int flog = 0;
//	    	Session session = sesss.openSession();
//			Connection con=session.connection();
//			String procedure = "{call [Proc_Edit_UserList](?,?,?)}";
//			CallableStatement cstmt;
//			tran = session.beginTransaction();
//			try {
//				cstmt = con.prepareCall(procedure);
//				cstmt.setInt(1, model.getId());
//				cstmt.setString(2,model.getName());
//				cstmt.setString(3, model.getPwd());
//				flog = cstmt.executeUpdate();
//				tran.commit();
//			} catch (SQLException e) {
//				e.printStackTrace();
//				tran.rollback();
//			}finally{
//				session.close();
//			}
	//
//			return flog;
//		}
	//	
//		/**
//		 * 删除
//		 * @param ID
//		 * @return
//		 */
		public void Delete(int id){
			
			UserList mode = Get(id);
			
			this.getHibernateTemplate().delete(mode);
			
		}
	//	
//		/**
//		 * 插入
//		 * @param model
//		 * @return
//		 */
//		public int Insert(UserList model){
//			int flog = 0;
//	    	Session session = sesss.openSession();
//			tran = session.beginTransaction();
//			Connection con=session.connection();
//			String procedure = "{call [Proc_Add_UserList](?,?)}";
//			CallableStatement cstmt;
//			try {
//				cstmt = con.prepareCall(procedure);
//				cstmt.setString(1,model.getName());
//				cstmt.setString(2, model.getPwd());
//				flog = cstmt.executeUpdate();
//				tran.commit();
//			} catch (SQLException e) {
//				e.printStackTrace();	
//				tran.rollback();
//			}finally{
//				session.close();
//			}
//			return flog;
//		}







	
}

⌨️ 快捷键说明

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