Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Login code

 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers!!
I'm doing a form design in java swing!!
now i developed the login dialog.. with username.. password.. and 2 buttons!!
After entering the username and password when i click the login button
it has to verify thru the code.. and if both are correct show..
Login success dialog!!
it is showing when i given some and checked it mandatory!!

when i connected it to database!! it is not showing error!!
each and everytime it is showing the incorrect password message box.. and finally when both the usename and pwd are correct shows the login success message box!!

now.. this is my code!!
for process login()
-------------------------------------------------------------------
public void processLogin()
{
try
{ try
{ Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e)
{ //out.println(e);
//JOptionPane.showMessageDialog(null, e);
System.exit(0);
}
String dbURL = "jdbc dbc:login";
Connection dbCon = DriverManager.getConnection(dbURL);
String query = "Select * from login";
Statement stmt = dbCon.createStatement();
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{ String data_name = rs.getString(1);
String data_pass = rs.getString(2);
//verfication part
if(name.equals(data_name))
{ if(pass.equals(data_pass))
{ JOptionPane.showMessageDialog(null, "Login Success");
break;
}
else
{ JOptionPane.showMessageDialog(null, "Invalid Password");

}
}
else
{ JOptionPane.showMessageDialog(null, "Authentication Failed !!");
}
}
}
catch(SQLException e)
{
System.exit(0);
}
}
---------------------------------------------------------------------

i think this code is correct
but when ever it passes thru the if conditions.. and if the username is incorrect it will be showing the messagebox "authentication failed "
------------------------------------------------------------------------

please help me ranchers!!

thanks in advance!!
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think this code is correct
but when ever it passes thru the if conditions.. and if the username is incorrect it will be showing the messagebox "authentication failed "


Quick glance at your code... Isn't that what it is supposed to be doing?

Henry
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Aravind,
I am going to format your code properly and you will see the answer to your question.


Now you will be able to see that the corresponding "else" block for the "if" block where the userName is checked prints out the "Authentication failed" message. So was it this that you wanted to know??
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Shyam Prasad Murarka,
thannks for the idea!!
but if i type the wrong user name it should be able to show the message box authentication failed!!
so.. for that.. what i want to do?
 
Jan Groth
Ranch Hand
Posts: 456
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pure curiosity: how did you put the double "!!" on you keyboard? did you have to remove any other keys for it?



jan
 
Shyam Prasad Murarka
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Aravind,
I am confused now! What are you trying to tell? Is the "Authentication Failed!!" message showing up or not when you type the wrong user name? Do you want it to show up?
And where did you get the habit of typing "!!"? Is it from the the constant number of sms-es that you keep sending?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic