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

📄 groupdao.java

📁 包括所有开发文档以及数据库文件
💻 JAVA
字号:
package dao;

import java.sql.*;


import bo.*;

public class GroupDAO {

	/**
	 * 根据角色查询组
	 * @param roleId
	 * @return
	 */
	public Group selectGroupByRole(String roleId) {


		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		String sql = "select * from groups where groupId in (select groupId from group_role where roleId=?);";

		try {

			con = DB.getConnection();
			pstmt = con.prepareStatement(sql);
			pstmt.setString(1, roleId);
			rs = pstmt.executeQuery();

			while (rs != null && rs.next()) {
				// 读到数据,生成实体类
				Group group = new Group();
				group.setGroupId(rs.getInt("groupId"));
				group.setGroupName(rs.getString("groupName"));
				group.setGroupDescription(rs.getString("groupDescription"));
				return group;
			}

			rs.close();
			pstmt.close();
			con.close();
		} catch (SQLException e) {
			e.printStackTrace();
		}

		return null;
	}

}

⌨️ 快捷键说明

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