首页 > 其他分享 >11.23

11.23

时间:2023-12-18 18:46:13浏览次数:19  
标签:String 11.23 UserID message null conn pstmt

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.*" %>
<html>
<body>

<%
request.setCharacterEncoding("UTF-8");
String UserID = (String) session.getAttribute("UserID");
String password = request.getParameter("password");
String password1 = request.getParameter("password1");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet existingRecord = null;
String message = ""; // 初始化message变量

try {
Class.forName("com.mysql.cj.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/fangchan?useSSL=false";
String name1 = "root";
String password2 = "123456";
conn = DriverManager.getConnection(url, name1, password2);
String query = "SELECT * FROM class3 WHERE UserID=? AND password=?";
pstmt = conn.prepareStatement(query);
pstmt.setString(1, UserID);
pstmt.setString(2, password);
existingRecord = pstmt.executeQuery();

if (existingRecord.next()) {
// 更新密码
String sql = "UPDATE class3 SET password = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, password1);
pstmt.executeUpdate(); // 执行更新查询

message = "修改成功!"; // 更新message变量
} else {
out.println("编号 " + UserID + " 不存在。");
}

} catch (SQLException | ClassNotFoundException e) {
System.out.println("发生错误: " + e.getMessage());
e.printStackTrace();
} finally {
try {
if (existingRecord != null) {
existingRecord.close();
}
if (pstmt != null) {
pstmt.close();
}
if (conn != null) {
conn.close();
}
} catch (SQLException e) {
System.out.println("关闭资源时发生错误: " + e.getMessage());
}
}

if (!message.isEmpty()) {
// 显示成功消息
out.println(message);
}
%>
</html>
<body>

标签:String,11.23,UserID,message,null,conn,pstmt
From: https://www.cnblogs.com/dmx-03/p/17911929.html

相关文章

  • 11.23
    今天实现前端的主页登录和管理员代码index.HTML<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>用户登录</title><style>button{display:block;mar......
  • 11.23
    1.编写程序,输入10个学生的学号、姓名、性别、年龄,统计其中女生有多少,男生有多少,并根据年龄从小到大对这10个学生重新排序。 程序代码:#include<stdio.h>#include<string.h> #defineN10 typedefstruct{   charid[10];   charname[20];   chargend......
  • 11.23
    今日学习内容<%@pageimport="java.sql.DriverManager"%><%@pageimport="java.sql.*"%><%--CreatedbyIntelliJIDEA.TochangethistemplateuseFile|Settings|FileTemplates.--%><%@pagecontentType="text/htm......
  • KubeSphere 社区双周报 | 苏州 Meetup 报名开启 | 2023.11.23-12.07
    KubeSphere社区双周报主要整理展示新增的贡献者名单和证书、新增的讲师证书以及两周内提交过commit的贡献者,并对近期重要的PR进行解析,同时还包含了线上/线下活动和布道推广等一系列社区动态。本次双周报涵盖时间为:2023.11.23-2023.12.07。贡献者名单新晋KubeSphereTale......
  • 聪明办法学python-11.23——11.26笔记打卡
      python的数据类型和操作1.数据类型和运算符:基本类型是:整形int  如1、34、-12浮点型float  如 1.23、-2.44布尔值bool  有真“True”假“False”  类型type 如:print(type(2))输出为:<class......
  • 11.23日记
    MapReduce是面向大数据并行处理的计算模型、框架和平台,它隐含了以下三层含义:(1)MapReduce是一个基于集群的高性能并行计算平台(ClusterInfrastructure)。它允许用市场上普通的商用服务器构成一个包含数十、数百至数千个节点的分布和并行计算集群。(2)MapReduce是一个并行计算与运行软件......
  • KubeSphere 社区双周报 | Fluent Operator 2.6.0 发布 | 2023.11.10-11.23
    KubeSphere社区双周报主要整理展示新增的贡献者名单和证书、新增的讲师证书以及两周内提交过commit的贡献者,并对近期重要的PR进行解析,同时还包含了线上/线下活动和布道推广等一系列社区动态。本次双周报涵盖时间为:2023.11.10-2023.11.23。贡献者名单新晋KubeSphereCont......
  • 敏捷冲刺11.23
    所属课程软件工程导论作业要求项目冲刺作业目标连续七天的敏捷冲刺github链接CampusSecond-handMarket--NoBailanGroup目录一、团队介绍1、团队名称:摆烂就不队2、团队成员二、站立式会议三、任务情况1、昨天已完成任务2.今天计划完成任务3、工作中遇到的困......
  • 2023.11.23——每日总结
    学习所花时间(包括上课):9h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习;我了解到的知识点:1.JavaGUI2.会话跟踪技术明日计划:学习......
  • 11.23每日总结
    /AbstractChatroom.javapackageorg.example.test017;importjavax.swing.plaf.basic.BasicTreeUI;publicabstractclassAbstractChatroom{publicabstractvoidregister(Membermember);publicabstractvoidsendText(Stringfrom,Stringto,Stringme......