Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2008, 07:55 PM
Member
 
Join Date: Nov 2008
Posts: 2
Rep Power: 0
bheezee is on a distinguished road
Default 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="jdbcdbc: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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to check password for 3 times enterd wrong password sk.mahaboobbhasha@gmail.c New To Java 2 11-14-2008 08:53 PM
how to check password for 3 times enterd wrong password sk.mahaboobbhasha@gmail.c Java Servlet 0 11-14-2008 02:22 PM
How to check password of a jsp/html with the password of Database(mysql) #1 sk.mahaboobbhasha@gmail.c Java Servlet 2 11-14-2008 02:11 PM
Help, created a username and password box cachi AWT / Swing 1 08-07-2007 05:21 AM
JTextFields with username & password. Eric AWT / Swing 2 07-02-2007 12:41 AM


All times are GMT +2. The time now is 04:32 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org