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

📄 logindao.java

📁 分为经理和出纳2个权限
💻 JAVA
字号:
package com.yiboit.cfss.login;

import java.sql.*;

import com.yiboit.cfss.db.ManageConnection;

public class LoginDAO {

	/**
	 * 根据指定的用户名查找用户信息
	 * 
	 * @param username
	 * @return
	 */
	public ShopUser getShopUserById(String username, String password) throws SQLException {
		ShopUser result = null;

		Connection conn = null;

		try {
			conn = ManageConnection.getConnection();
			String sql = "select * from shop_user where username = ? and password = ?";
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, username);
			pstmt.setString(2, password);
			
			ResultSet rs = pstmt.executeQuery();

			if (rs.next()) {
				result = new ShopUser(username, rs.getString("password"), rs
						.getString("flag"));
			} 
		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		} finally {
			if (conn != null) {
				try {
					conn.close();
				} catch (SQLException e) {
				}
			}
		}

		return result;
	}
}

⌨️ 快捷键说明

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