Loading

Help on changing password code by user using java

Submitted by: 


Hello Sir.

I have difficulty writting out the code to reset user password in the database after login into the application.

Here is my code

char[] oldPass = jPasswordField1.getPassword();
String strOldPass = new String(oldPass);

char[] newPass = jPasswordField2.getPassword();
String strNewPass = new String(newPass);

char[] confPass = jPasswordField3.getPassword();
String strConfPass = new String(confPass);

try
{
Inventory objInven = new Inventory();//creating of the objectof the connection in class Inventory.

Statement stmt = objinven.con.createStatement();
ResultSet rs = stmt.getResult();

while(rs.next())
{
if(rs.getsring("Password").equals(strOldPass))
{
rs.moveToInserRow();
rs.updateString("Password", strNewPass);
rs.updateString("Password", strConfPass);

if(strNewPass.equals(strConfPass))
{
JOptionPane.showMessageDialog(this, "Password change successfuly");
}
else
{JOptionPane.showMessageDialog(this, "Password do not match");
}
}
else
{
JOptionPane.showMessageDialog(this, "Wrong old Password");

}
}
catch(SQLException ex)
{
ex.printStackTrace();
}
}

this code is to be performed when a submit button is clicked.
i have this error : Exception occurred during event dispatching: jana.lang.NullPointerException.

please help me out with this code that will allow users to change their old password to a new one in the database created by correcting my error

Thanx




Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.