Friday, August 3, 2018


    JSP(Java Server Page): how to Change Password from database in using mysql
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>update</title>
</head>
<body>
<%!
        Connection con;PreparedStatement st;
        String a,b;
%>
<%
a=request.getParameter("Password");
b=request.getParameter("oldPassword");
%>
<%
       
        try
        {
               Class.forName("com.mysql.jdbc.Driver");
               con=DriverManager.getConnection("jdbc:mysql://
                   localhost:3306/sts","root","root");
               String str="Update sts.users set Password=? Where
                            password=?";      
               st=con.prepareStatement(str);
               st.setString(1,a);
               st.setString(2,b);
               st.executeUpdate();
               out.print("recordUpdated");
        }
        catch(Exception e)
        {
               out.print(e.toString());
        }
%>
</body>
</html>


No comments:

Post a Comment