0

hi all
i m making a project using jsp as my front end and mysql as my back end.
i had to change backend from oracle to mysql bcoz of clients request.
now there is 1 problem i m facing.
there a password change option.
person enters its old password and then new password twice n clicks on submit.
although the password gets changed but it shows the else part,that the password is not changed.
this was working fine with oracle but no with mysql.
what could b the problem

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by peter_budo
0

Oracle and mysql use two different password encryption algorithms.
Are you talking about the password to connect to the database, or a password for user authentication?
How did you store the password in the database? Plain text, MD5, homegrown hash?
Could you post the relevant code? not the whole file , just the call to teh databse (minus your user&oass for the DB)

0

hi bro.
thanks for ur reply.
i m asking for password for user authentication.
the code i m using is

<%@ page errorPage="changepassword_error.jsp" import="java.sql.*" %>
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>:: Intranet ::</title>
<link href="tools/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%!
 Connection con;
 Statement st;
 ResultSet rs;
%>
<%
 if(session.getAttribute("theName")==null){
 response.sendRedirect("index_session.html");
}
 session.getAttribute("theName");
 String s2=request.getParameter("T2");
 String s3=request.getParameter("T3");
 try{
 //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 //con=DriverManager.getConnection("jdbc:odbc:index","scott","tiger");
 Class.forName("com.mysql.jdbc.Driver");
 String url ="jdbc:mysql://localhost:3306/Timesheet";
 con =DriverManager.getConnection(url,"root", "");
 st=con.createStatement();
 int p=st.executeUpdate("update userTab set password='"+s3+"' where uname='"+session.getAttribute("theName")+"' and password='"+s2+"'");
 if(p==1)
 {
 //  response.sendRedirect("index.html");
 //out.println("Password saved successfully!!!!!!!!!!!!!!");
%>
<script type="text/javascript">
 alert("You have changed your password successfully!")
 //window.history.load("mainscreen.jsp")
 window.location.assign("index.html")
</script>
<!--<table width="100%" border="0" cellpadding="0" cellspacing="0" class="base">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="150">
          <img src="images/logo.gif" alt="" /></td>
          <td class="top-bg">&nbsp;</td>
          <td width="196">
          <img src="images/top_right.gif" alt="" /></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="22" class="top-menu"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td></td>
          <td></td>
        </tr>
      </table></td>
  </tr>
<table align="center"><tr><td><img src="images/trans.gif" alt="" width="20" height="10" ></td><td valign="bottom" height="30" ><font color="red"><b>Your password has changed successfully!</td></tr>
<tr height="30" align="center">
<td></td><td><a href="mainscreen.jsp">OK</a>
</td>
</tr></table>-->
<%
 }
 else{
 %>
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="base">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="150">
          <img src="images/logo.gif" alt="" /></td>
          <td class="top-bg">&nbsp;</td>
          <td width="196">
          <img src="images/top_right.gif" alt="" /></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td height="22" class="top-menu"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td><!--<span class="welcome">Welcome! Shalini</span> Today is 11th Jan--></td>
          <td align="right"><font color="white"><a href="mainscreen.jsp">Main menu</a> | <a href="changepassword.html">Change password</a> | <a href="logout.jsp">Logout</a></td>
        </tr>
      </table></td>
  </tr>
<table align="center"><tr><td><img src="images/trans.gif" alt="" width="20" height="10" ></td><td valign="bottom" height="30" ><font color="red"><b>Password mismatch! Please try again.</td></tr>
<tr height="30" align="center">
<td></td><td><a href="mainscreen.jsp">OK</a>
</td>
</tr></table>
<%
   //out.println("Please try again.....................");
     }
   }catch(Exception ee){out.println(ee);}
%>

</body>
</html>
0

It is bad idea to setup conection to DB in JSP. It is all fashioned and left only for back compability from dark age of Java Web Development. You better of using servlets to handle connection and changes to DB

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.