RSS Forums RSS
Please support our MySQL advertiser: Programming Forums
Views: 1652 | Replies: 3
Reply
Join Date: Mar 2007
Location: India
Posts: 28
Reputation: bhuvan83 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bhuvan83's Avatar
bhuvan83 bhuvan83 is offline Offline
Light Poster

help required mysql+jsp

  #1  
Mar 23rd, 2007
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
Last edited by bhuvan83 : Mar 23rd, 2007 at 6:59 am.
Bhuvan Aggarwal
There is no word impossible.
its i m possible
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2006
Location: NYC
Posts: 133
Reputation: sn4rf3r is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 2
sn4rf3r's Avatar
sn4rf3r sn4rf3r is offline Offline
Junior Poster

Re: help required mysql+jsp

  #2  
Mar 23rd, 2007
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)
Reply With Quote  
Join Date: Mar 2007
Location: India
Posts: 28
Reputation: bhuvan83 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
bhuvan83's Avatar
bhuvan83 bhuvan83 is offline Offline
Light Poster

Re: help required mysql+jsp

  #3  
Mar 26th, 2007
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>
Bhuvan Aggarwal
There is no word impossible.
its i m possible
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,657
Reputation: peter_budo is just really nice peter_budo is just really nice peter_budo is just really nice peter_budo is just really nice 
Rep Power: 12
Solved Threads: 311
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: help required mysql+jsp

  #4  
Mar 26th, 2007
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
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 4:50 am.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC