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

📄 logindaoimpl.java

📁 这是大唐电信的一个管理系统
💻 JAVA
字号:
package com.tatang.dao.impl;

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

import com.tatang.dao.ILoginDao;
import com.tatang.util.HibernateSessionFactory;

public class LoginDaoImpl implements ILoginDao{

	public boolean validate(String name, String pwd, String position, boolean is) {
		Session session = null;
		Transaction tx = null;
		Query q = null;
		Integer it = -1;
		String sql="select count(*) from TEmployee where name=? and password=? and position=?";
		try{
			session = HibernateSessionFactory.getSession();
			tx = session.beginTransaction();
			q = session.createQuery(sql);
			q.setString(0,name);
			q.setString(1, pwd);
			q.setString(2,position);
			
			it = (Integer)q.uniqueResult();
			tx.commit();
			if(it != 0){
				return true;
			}else{
				return false;
			}
		}catch(HibernateException e){
			tx.rollback();
			e.printStackTrace();
			return false;
		}finally{
			HibernateSessionFactory.closeSession();
		}
	}

	public Integer validate(String name, String pwd, String position) {
		Session session = null;
		Transaction tx = null;
		Query q = null;
		int is = 0;
		String sql="select id from TEmployee where name=? and password=? and position=?";
		try{
			session = HibernateSessionFactory.getSession();
			tx = session.beginTransaction();
			q = session.createQuery(sql);
			q.setString(0,name);
			q.setString(1,pwd);
			q.setString(2,position);
			is =(Integer)q.uniqueResult();
			tx.commit();
			return is;
		}catch(HibernateException e){
			tx.rollback();
			e.printStackTrace();
			return 0;
		}finally{
			HibernateSessionFactory.closeSession();
		}
	}
}

⌨️ 快捷键说明

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