954,554 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Frame

import java.sql.*;
import javax.sql.*;
import javax.swing.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.*;
public class Display extends JFrame implements ActionListener
{

JLabel l1;
JTextField t1,t2;
JButton b1,b2;
 public Display(String s)
{
super(s);

l1 = new JLabel("user name");
b1 = new JButton("submit");
b2 = new JButton("reset");
t1 = new JTextField(20);
t2 = new JTextField(20);

Panel p = new Panel();
p.setLayout(new GridLayout(2,2));
p.add(l1);
p.add(t1);
p.add(b1);
p.add(b2);
p.add(t2);
add(p);
b1.addActionListener(this);
b2.addActionListener(this);
}
public  static void main(String args[])
{
Display d = new Display("main frame");
d.setVisible(true);
d.setSize(300,300);
}
public void actionPerformed(ActionEvent ae)
{
String k;
String m="";
k = ae.getActionCommand();
if(k=="submit" )
{
String x = t1.getText();

Connection conn;
ResultSet r =null;

    
           
      try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");       
                conn=DriverManager.getConnection("jdbc:odbc:aanchal");
             
                Statement stmt = conn.createStatement(); 
 	     r =stmt.executeQuery("select * from id");


 
  	
         while (r.next())
         {
               
         m = r.getString(1);
         
System.out.println(m);
try{
if(x.equals("m"))
{
t2.setText("authenticated");
}
else
{
t2.setText("invalid");
}
}

catch(Exception e)
{
System.out.println(e.getMessage());
}
}

																		


      r.close();
         stmt.close();
         conn.close();
      } 
     
      catch (ClassNotFoundException e) 
        { 
            System.out.println( e.getMessage());
            
         
}

catch(SQLException e)
{
System.out.println(e.getMessage());
}
  }


else if(k=="reset")
{
t1.setText("");
t2.setText(""); 

}
}

}
Aanchal89
Newbie Poster
1 post since Aug 2010
Reputation Points: 10
Solved Threads: 0
 

Is this a question or what?

JamesCherrill
Posting Genius
Moderator
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: