473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to make this in limiting 3 login attempt

How do I make this in limited to 3 login attempts:
Expand|Select|Wrap|Line Numbers
  1. try{
  2.             stmt = con.createStatement();
  3.             rs = stmt.executeQuery("SELECT * FROM SECURITY WHERE USERNAME = '" + username.getText() + "'");
  4.             if (rs.next()){
  5.                 if (rs.getString("PASSWORD").equals(password.getText())){
  6.                     addRecordMenuItem.setEnabled(true);
  7.                     deleteRecordMenuItem.setEnabled(true);
  8.                     updateRecordMenuItem.setEnabled(true);
  9.                     addRecordButton.setEnabled(true);
  10.                     deleteRecordButton.setEnabled(true);
  11.                     updateRecordButton.setEnabled(true);
  12.                     loginInternalFrame.setVisible(false);
  13.                     loginMenuItem.setText("Logout");
  14.                     username.setText("");
  15.                     password.setText("");
  16.                 }else{
  17.                     JOptionPane.showMessageDialog(rootPane, "Incorrect password");
  18.                 }
  19.             } else {
  20.                 JOptionPane.showMessageDialog(rootPane, "Username does not exist");
  21.             }
  22.         }catch(Exception e){
  23.             JOptionPane.showMessageDialog(this, e);
  24.         }
Aug 28 '17 #1
1 2803
Frinavale
9,735 Expert Mod 8TB
If you want your application to simply close after 3 attempts:
  • Declare a variable called failedAttempts
  • Increment failedAttempts every time the user fails to log in
  • Close the application if failedAttempts is greater than 3

If the user re-opens the application, it will let him attempt to log in 3 more times and then close.

If you don't want this type of behaviour, consider keeping a table in your database that tracks who has failed to log in. This requires more work and you need to determine when this table is cleaned up etc.
Aug 28 '17 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: VB Programmer | last post by:
ASP.NET 2.0 site... On my dev maching I can run my login page with no problem. After I sign in it redirects to the proper secured page. I deployed the site, with the same database. I can't...
18
by: Gleep | last post by:
I've searched google intensely on this topic and it seems noone really knows how to approch this. The goal I don't want clients to give out their usernames and passwords to friends, since the site...
2
by: Ronald S. Cook | last post by:
I have a Win app wherein users login via my interface (i.e. not via NT Authentication). Since the User Names are like "Driver 1, Driver 2, etc., sometimes Driver 1 might accidentally login as...
6
by: phamn1985 | last post by:
I m trying to make a login page via Microsoft access. This is my table .. Table name : tblLogin PK : loginID(Auto number) Attributes : username , password. I make a login form in Microsoft...
0
by: muder | last post by:
I have a standard Login ASP.NET 2.0 control on a login Page, a LoginName and LoginStatus controls on the member's page. once the user login successfully I am redirecting the user to Member.aspx...
1
by: =?Utf-8?B?SHVzYW0=?= | last post by:
Hi fveryBody: How can I make my login page in my web site that made by asp.net 2.0, used the https:// protocal . any help will be appreciated regard husam
18
by: icesh | last post by:
hi i'm a newbie in php.. can you help me how to make several login attempt in php? (if we put wrong password/username,, we will go back to the previous form and we can try 3 more attempts to input...
0
by: JAYAN NAIR | last post by:
dear i am developing a software in vb 6 i want to know how to create a login dialoge with user name and password i craeted a file named sp.mdf with a table 'sp' the field is password help me
6
benchpolo
by: benchpolo | last post by:
Private Sub cmdProcess_Click() DoCmd.SetWarnings False Dim rs As ADODB.Recordset Dim rsv As ADODB.Recordset Dim cnCurrent As ADODB.Connection Dim strSql As String ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.