Results 1 to 1 of 1
Thread: username password verification
- 11-25-2008, 06:55 PM #1
Member
- Join Date
- Nov 2008
- Posts
- 2
- Rep Power
- 0
username password verification
hi guys...
can anyone provide me with the code for username n password verification using the JDBC & Microsoft Access?
import java.awt.*;
import javax.swing.*;
import javax.swing.text.MaskFormatter;
import java.text.*;
import java.awt.event.*;
import java.util.*;
import java.io.*;
import java.sql.*;
public class Login extends JFrame implements ActionListener
{
private Container MainPanel=getContentPane();
private JPanel Panel1 = new JPanel (new FlowLayout());
private JPanel Panel2 = new JPanel ();
private JPanel Panel3 = new JPanel (new FlowLayout());
private JPanel Panel4 = new JPanel (new FlowLayout());
private JPanel Panel5 = new JPanel (new FlowLayout());
private JTextField TextField1 = new JTextField(10);
private JLabel MainTitle = new JLabel("Student Grade Management System");
private JLabel Label1 = new JLabel("Username :");
private JLabel Label2 = new JLabel("Password :");
private JLabel EmptyLabel = new JLabel(" ");
private JLabel LabelEmpty = new JLabel(" ");
private JPasswordField passwordField = new JPasswordField(10);
private JButton LoginButton=new JButton("Login");
//declare an action for the accelerator buttons
protected Action ClickButton = new AbstractAction()
{
public void actionPerformed(ActionEvent ae)
{
((JButton)ae.getSource()).doClick();
}
};
public void loginScreen()
{
setTitle("Student Grade Management System");
setLocation(450,250);
setSize(370,150);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
MainPanel.setLayout(new BorderLayout());
LoginButton.setEnabled(true);
Panel1.add(MainTitle);
MainTitle.setFont(new Font("System",Font.BOLD,20));
MainPanel.add(Panel1,BorderLayout.NORTH);
//add items to second panel
GroupLayout GLayout = new GroupLayout(Panel3);
GLayout.setAutoCreateGaps(true);
GLayout.setHorizontalGroup
(
GLayout.createSequentialGroup()
.addGroup(GLayout.createParallelGroup(GroupLayout. Alignment.LEADING)
.addComponent(EmptyLabel)
.addComponent(EmptyLabel)
)
.addGroup(GLayout.createParallelGroup(GroupLayout. Alignment.LEADING)
.addComponent(Label1)
.addComponent(Label2)
)
.addGroup(GLayout.createParallelGroup(GroupLayout. Alignment.LEADING)
.addComponent(TextField1,GroupLayout.PREFERRED_SIZ E,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_S IZE)
.addComponent(passwordField,GroupLayout.PREFERRED_ SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRE D_SIZE)
)
);
GLayout.setVerticalGroup
(
GLayout.createSequentialGroup()
.addGroup(GLayout.createParallelGroup(GroupLayout. Alignment.BASELINE)
.addComponent(EmptyLabel)
.addComponent(Label1)
.addComponent(TextField1,GroupLayout.PREFERRED_SIZ E,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRED_S IZE)
)
.addGroup(GLayout.createParallelGroup(GroupLayout. Alignment.BASELINE)
.addComponent(EmptyLabel)
.addComponent(Label2)
.addComponent(passwordField,GroupLayout.PREFERRED_ SIZE,GroupLayout.DEFAULT_SIZE,GroupLayout.PREFERRE D_SIZE)
)
);
Panel3.setLayout(GLayout);
MainPanel.add(Panel3,BorderLayout.CENTER);
LoginButton.addActionListener(this);
Panel4.add(LoginButton);
MainPanel.add(Panel4,BorderLayout.SOUTH);
;
}
private void gotoStudent()
{
Student student = new Student();
setVisible(false);
student.study();
}
public void actionPerformed(java.awt.event.ActionEvent e)
{
if(e.getActionCommand().equals("Login")){
JOptionPane.showMessageDialog(null,"Wrong Username or Password",JOptionPane.WARNING_MESSAGE);
}
else
{
int respond=JOptionPane.showConfirmDialog(null,"WOULD YOU LIKE TO EXIT?","Exiting",JOptionPane.YES_NO_OPTION);
//System.out.println(respond);
if(respond==0)
{
dispose();
}
}
public static void connect();
{
Connection conn=null;
try
{
String userName="root";
String password="root";
String url="jdbc:odbc:StudentManagement";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newI nstance();
conn=DriverManager.getConnection(url,userName,pass word);
System.out.println("Database Connection Established");
}
catch(Exception e)
{
System.err.println("Cannot connect");
}
finally
{
try{
conn.close();
System.out.println("database connection terminated");
}
catch(Exception e)
{
/*ignore*/
}
}
}//connect()
}
public static void main(String[]args)
{
Login Log=new Login();
Log.loginScreen();
connect();
}
}
ive searched onlien n i got sth like this
bt it cant compile.my codes are wrong
sorry.im a noobie in this n this is for my assignment
Similar Threads
-
how to check password for 3 times enterd wrong password
By sk.mahaboobbhasha@gmail.c in forum New To JavaReplies: 2Last Post: 11-14-2008, 07:53 PM -
how to check password for 3 times enterd wrong password
By sk.mahaboobbhasha@gmail.c in forum Java ServletReplies: 0Last Post: 11-14-2008, 01:22 PM -
How to check password of a jsp/html with the password of Database(mysql) #1
By sk.mahaboobbhasha@gmail.c in forum Java ServletReplies: 2Last Post: 11-14-2008, 01:11 PM -
Help, created a username and password box
By cachi in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 04:21 AM -
JTextFields with username & password.
By Eric in forum AWT / SwingReplies: 2Last Post: 07-01-2007, 11:41 PM


LinkBack URL
About LinkBacks

Bookmarks