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

📄 roleinfodao.java

📁 J2ee开发的 人事管理系统 使用oracle数据库 myeclips平台开发
💻 JAVA
字号:
package com.galaxy.dao;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.galaxy.base.DaoInterface;
import com.galaxy.db.ConnectDB;
import com.galaxy.vo.LevelInfoVO;
import com.galaxy.vo.RoleInfoVO;

public class RoleInfoDAO extends ConnectDB implements DaoInterface{

	public int addObject(Object ob) {
		int i = 0;
		RoleInfoVO rolevo = new RoleInfoVO();
		rolevo = (RoleInfoVO)ob;
		String sql = "insert into role_info values(galaxy.seq.nextval,?,?,?)";
		super.openDBConnection();
		try {
			PreparedStatement pst = super.dbConnection.prepareStatement(sql);
			pst.setString(1, rolevo.getRiName());
			pst.setString(2, rolevo.getRiTag());
			pst.setString(3, "");
			i = pst.executeUpdate();
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		super.closeDBConnection();
		return i;
	}

	public int deleteObject(Object cond) {
		int result = 0;
		String sql = "delete from role_info where ri_id in("+(String)cond+")";
		super.openDBConnection();
		try {
			result = super.dbStatement.executeUpdate(sql);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		super.closeDBConnection();
		return result;
	}

	public List queryByCondition(Object cond) 
	{
		List roles = new ArrayList();
		super.openDBConnection();
		String sql = "select * from role_info where 1=1 " + cond;
		try
		{
			super.dbResultSet = super.dbStatement.executeQuery(sql);
			while(super.dbResultSet.next())
			{
				RoleInfoVO rolevo = new RoleInfoVO();
				rolevo.setRiId(dbResultSet.getLong("ri_id"));
				rolevo.setRiName(dbResultSet.getString("ri_name"));
				rolevo.setRiTag(dbResultSet.getString("ri_tag"));
				rolevo.setRiExtend(dbResultSet.getString("ri_extend"));
				roles.add(rolevo);
			}
		}
		catch(SQLException e)
		{
			e.printStackTrace();
		}
		super.closeDBConnection();
		return roles;
	}

	public Object readObject(Object cond) 
	{
		RoleInfoVO rolevo = (RoleInfoVO)cond;
		super.openDBConnection();
		String sql = "select * from role_info where ri_id = ?";
		try
		{
			PreparedStatement pst = super.dbConnection.prepareStatement(sql);
			pst.setLong(1, rolevo.getRiId());
			super.dbResultSet = pst.executeQuery();
			while(super.dbResultSet.next())
			{
				rolevo.setRiName(dbResultSet.getString("ri_name"));
				rolevo.setRiTag(dbResultSet.getString("ri_tag"));
				rolevo.setRiExtend(dbResultSet.getString("ri_extend"));
			}			
		}
		catch(SQLException e)
		{
			e.printStackTrace();
		}
		super.closeDBConnection();
		return rolevo;
	}

	public int updateObject(Object ob) {
		RoleInfoVO rolevo = (RoleInfoVO)ob;
		int i = 0;
		String sql = "update role_info set ri_name=?, ri_tag=?, ri_extend=? where ri_id=?";
		super.openDBConnection();
		try {
			PreparedStatement pst = super.dbConnection.prepareStatement(sql);
			pst.setString(1, rolevo.getRiName());
			pst.setString(2, rolevo.getRiTag());
			pst.setString(3, rolevo.getRiExtend());
			pst.setLong(4, rolevo.getRiId());
			i = pst.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		super.closeDBConnection();
		return i;
	}

}

⌨️ 快捷键说明

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