I want to display result when a student enter their rollno in a text box and click on the submit button.
I know there are errors as i have tried many times before and each time i have changed it so
Please help me in locating errors.I need it early.
Thanks.
import java.awt.*;
import java.awt.TextField;
import java.awt.Label;
import java.awt.Button;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.*;
import java.sql.Connection;
import java.sql.*;
import java.sql.DriverManager;
import java.sql.Statement;
class res extends Frame implements ActionListener
{
Connection con;
Statement st;
ResultSet rs;
List lP1=new List();
List lP2=new List();
List lP3=new List();
List lP4=new List();
List lP5=new List();
Label res=new Label("Result");
Label P1=new Label("P1");
Label P2=new Label("P2");
Label P3=new Label("P3");
Label P4=new Label("P4");
Label P5=new Label("P5");
Button b1=new Button("Submit");
Button b2=new Button("Cancel");
TextField msg=new TextField(200);
public res()
{
setLayout(null);
setVisible(true);
setSize(900,900);
res.setBounds(320,50,650,20);
P1.setBounds(200,80,80,30);
P2.setBounds(280,80,80,30);
P3.setBounds(370,80,80,30);
P4.setBounds(440,80,80,30);
P5.setBounds(520,80,80,30);
lP1.setBounds(200,130,80,150);
lP2.setBounds(280,130,80,150);
lP3.setBounds(360,130,80,150);
lP4.setBounds(440,130,80,150);
lP5.setBounds(520,130,80,150);
msg.setBounds(100,400,300,20);
b1.setBounds(320,370,60,20);
b2.setBounds(250,300,50,20);
add(res);
add(P1);
add(P2);
add(P3);
add(P4);
add(P5);
add(lP1);
add(lP2);
add(lP3);
add(lP4);
add(lP5);
add(b1);
add(b2);
add(msg);
b1.addActionListener(this);
b2.addActionListener(this);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:student");
st=con.createStatement();
}
catch(Exception e)
{
System.out.println(e);
}
}
public void actionPerformed(ActionEvent ae)
{
try
{
if(ae.getSource()==b1)
{
ResultSet rest=st.executeQuery("select * from result where result='"+ b1 + "'");
if(rest.next())
{
msg.setText("Result");
return;
}
else if(ae.getSource()==b2)
{
dispose();
}
}
}
catch(Exception e)
{
System.out.println(e);
}
}
public void keyTyped(KeyEvent ke)
{
}
public void keyPressed(KeyEvent ke)
{
}
public void keyReleased(KeyEvent ke)
{
}
}
class result
{
public static void main(String as[])
{
res demo=new res();
}
}