changepwddao.java

来自「分为经理和出纳2个权限」· Java 代码 · 共 38 行

JAVA
38
字号
package com.yiboit.cfss;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.yiboit.cfss.db.ManageConnection;

public class ChangePwdDAO {
	
	public boolean savePwd(String userName, String pwd) throws SQLException {
		boolean result = false;
		Connection conn = null;

		try {
			conn = ManageConnection.getConnection();
			String sql = "update shop_user set password = ? "
					+ " where username = ? ";
			PreparedStatement pstmt = conn.prepareStatement(sql);
			pstmt.setString(1, pwd);
			pstmt.setString(2, userName);

			result = pstmt.executeUpdate() == 1 ? true : false;
		} 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 + =
减小字号Ctrl + -
显示快捷键?