Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: My Code is not working [URGENT] Help Needed

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default My Code is not working [URGENT] Help Needed

    Let's get Straight. I m developing an application based on the integration of JDBC and Swing.

    I m stuck with the output. It always give unexpected error. My problem is that sometimes i can input the value and retrieve those in JTable but sometimes it shows me Error even if i hvn't change any code.

    Here is the table which i hv made in Oracle 10.2g Express Edition:
    ---------------------------------------------------------------

    create table recstudent(name varchar2(25),year number(4), branch varchar2(20),company varchar2(20),package number(12),location varchar2(25));
     
    create table recruitment(name varchar2(20),rounds number(2),question varchar2(900));
     
    create table studentpro(name varchar2(20),gname varchar2(20),regno number(10),branch varchar2(20),year number(4),address varchar2(40),phno number(11),avgsemmark number(4,2),backlog number(3),qualify varchar2(25),careerpercent number(4,2));
     
    create table minor(name varchar2(20),year number(4),branch varchar2(20),prjname varchar2(20),abstract varchar2(900));
     
    create table major(name varchar2(20),year number(4),branch varchar2(20),prjname varchar2(20),abstract varchar2(900));
     
    create table seminar(name varchar2(20),year number(4),branch varchar2(20),topic varchar2(20),abstract varchar2(900));



    I have attach the code on which i am working.


    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.sql.*;
     
    public class DatabaseRough extends JFrame implements ActionListener
    {
        JFrame f,abc,pqr,abq,rtf,rog,ros;
        JPanel ab1,ab2,p1,p2,p3,p4,a1,a2,b1,b2,po1,po2,pol1,pol2,poh1,poh2;
        JTabbedPane tp,bq,bqr,adp,post,pot,pog;
        JButton zp1,zp2,zp3,zpg1,zpg2,zpg3,zpq1,zpq2,zpq3,z1,z2,z3,sub1,can1,dis1,jb2,jb21,disp,studentbtn,miprojectbtn,maprojectbtn,seminarbtn,submitback,career1,career2,dispcareer,req,stubtn;
        JLabel dp1,dp2,dp3,dp4,dp5,dpg1,dpg2,dpg3,dpg4,dpg5,dpq1,dpq2,dpq3,dpq4,dpq5,pb1,pb2,pb3,pb4,pb5,pb6,pb7,pb8,pb9,pb10,pb11,ro1,ro2,ro3,l1,l2,l3,jl2,jl3,jl4,jl5,jl6,jl7;
        JTextField gp1,gp2,gp3,gp4,gp5,gpg1,gpg2,gpg3,gpg4,gpg5,gpq1,gpq2,gpq3,gpq4,gpq5,g1,g2,g3,g4,g5,g6,g7,g8,g9,g10,g11,fi1,fi2,fi3,tf1,tf2,jt2,jt3,jt4,jt5,jt6,jt7;
     
        // MAIN LAYOUT
        DatabaseRough()
        {
            f=new JFrame("DATABASE DETAILED");
            p1=new JPanel();
            p2=new JPanel();
            p3=new JPanel();
            p4=new JPanel();
            tp=new JTabbedPane();
            studentbtn = new JButton(" STUDENT DETAILS ");
            miprojectbtn = new JButton(" MINOR PROJECT PROFILE ");
            maprojectbtn = new JButton(" MAJOR PROJECT PROFILE ");
            seminarbtn = new JButton(" SEMINAR PROFILE ");
            submitback = new JButton(" DISPLAY ");
            career2 = new JButton(" CAREER > 60 % ");
            career1 = new JButton(" CAREER < 60 % ");
            dispcareer = new JButton(" DISPLAY CAREER ");
            req = new JButton(" RECRUITMENT DETAIL ");
            stubtn = new JButton(" STUDENT DETAIL ");
            l1=new JLabel(" FILTERING OPTION : ");
            l2=new JLabel(" ENTER THE NUMBER OF BACKLOGS : ");
            tf1=new JTextField(2);
            l3=new JLabel(" ENTER THE CAREER PERCENTAGE : ");
            tf2=new JTextField(2);
            p1.add(studentbtn);
            p1.add(miprojectbtn);
            p1.add(maprojectbtn);
            p1.add(seminarbtn);
            p2.add(career1);
            p2.add(career2);
            p2.add(l3);
            p2.add(tf2);
            p2.add(dispcareer);
            p3.add(l1);
            p3.add(l2);
            p3.add(tf1);
            p3.add(submitback);
            p4.add(req);
            p4.add(stubtn);
            miprojectbtn.addActionListener(this);
            career1.addActionListener(this);
            career2.addActionListener(this);
            dispcareer.addActionListener(this);
            studentbtn.addActionListener(this);
            req.addActionListener(this);
            stubtn.addActionListener(this);
            submitback.addActionListener(this);
            maprojectbtn.addActionListener(this);
            seminarbtn.addActionListener(this);
        }
     
     
     
     
        // "SEMINAR PROFILE " LAYOUT of "STUDENT PROFILE Section"
     
        public class seminar extends JFrame
        {
            public seminar()
            {
                try
                {
                    ros = new JFrame("STUDENT DETAILS ....");
                    poh1 = new JPanel();
                    poh2 = new JPanel();
                    pog = new JTabbedPane();
                    ros.getContentPane().add(pog);
                    pog.addTab(" ADD NEW ...",poh1);
                    pog.addTab(" DISPLAY ...",poh2);
                    dpg1=new JLabel("Name of the Student :");
                    dpg2=new JLabel("Year :");
                    dpg3=new JLabel("Branch :");
                    dpg4=new JLabel("Seminar Topic :");
                    dpg5=new JLabel("Abstract :");
                    gpg1=new JTextField(20);
                    gpg2=new JTextField(4);
                    gpg3=new JTextField(20);
                    gpg4=new JTextField(20);
                    gpg5=new JTextField(900);
                    zpg1=new JButton("SUBMIT");
                    zpg2=new JButton("CANCEL");
                    zpg3=new JButton("DISPLAY RECORDS");
                    poh1.add(dpg1);poh1.add(gpg1);
                    poh1.add(dpg2);poh1.add(gpg2);
                    poh1.add(dpg3);poh1.add(gpg3);
                    poh1.add(dpg4);poh1.add(gpg4);
                    poh1.add(dpg5);poh1.add(gpg5);
                    poh1.add(zpg1);poh1.add(zpg2);
                    poh2.add(zpg3);
                    ros.setSize(500,500);
                    ros.setVisible(true);
                    ros.repaint();
                     // HANDLES WHEN "CANCEL" BUTTON IS CLICKED
                     zpg2.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==zpg2)
                            {
                                ros.dispose();
                            }
                        }
                        });
     
                     zpg3.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==zpg3)
                            {
                                // object refrence of "report" is used
                                JFrame frm = new viewseminar();
                                   frm.setSize(600, 600);
                                   frm.setLocation(50,50);
                                   frm.setVisible(true);
     
                            }
                        }
                        });
     
                     // HANDLES WHEN "SUBMIT"  BUTTON OF RECRUIMENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    zpg1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==zpg1)
                            {
                            String value1=gpg1.getText();
                            String value2=gpg2.getText();
                            String value3=gpg3.getText();
                            String value4=gpg4.getText();
                            String value5=gpg5.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into seminar(name,year,branch,topic,abstract) values(?,?,?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.setString(4,value4);
                                st.setString(5,value5);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(ros,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(ros,"Error in submitting data!");
                             }
                           }
                          }
                        });
                }
                catch(Exception exe){}
            }
        }
     
     
     
        // DISPLAY SEMINAR PROJECT RECORDS(SEMIANR PROFILE) IN STUDENT PROFILE SECTION
     
        public class viewseminar extends JFrame
           {
                    PreparedStatement ps;
                    Connection con;
                    ResultSet rs;
                    Statement st;
                    JLabel l1;
                    String nam,br,topic,abs;
                    int yr;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane scroller;
                    JTable table;
                    public viewseminar()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   st = con.createStatement ();	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=st.executeQuery("SELECT * from seminar");
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                yr = rs.getInt(2);
                                                br = rs.getString(3);
                                                topic = rs.getString(3);
                                                abs = rs.getString(3);
                                                rows++;
                                         }
                                    data1=new Object[rows][5];
                                    Object[] Colheads={"name","year","branch","seminar-topic","abstract"};
                                    rs=st.executeQuery("Select * from seminar");
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<5;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     JTable table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     JScrollPane jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                       }
                                try{
                                        data1=new Object[rows][5];
                                        Object[] Colheads={"name","year","branch","seminar-topic","abstract"};
                                        rs=st.executeQuery("Select * from seminar");
                                        for(int i1=0;i1<rows;i1++)
                                            {
                                                 rs.next();
                                                 for(int j1=0;j1<5;j1++)
                                                     {
                                                             data1[i1][j1]=rs.getString(j1+1);
                                                     }
                                            }
                                        JTable table=new JTable(data1,Colheads);
                                        int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                        int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                        JScrollPane jsp=new JScrollPane(table,v,h);
                                        getContentPane().add(jsp);
     
                                   }
                                    catch(Exception e)
                                    {
                                    }
                        setVisible(true);
                         //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
     
     
     
     
        // "MAJOR PROJECT PROFILE " LAYOUT of "STUDENT PROFILE Section"
     
        public class majorpp extends JFrame
        {
            public majorpp()
            {
                try
                {
                    rog = new JFrame("STUDENT DETAILS ....");
                    pol1 = new JPanel();
                    pol2 = new JPanel();
                    pot = new JTabbedPane();
                    rog.getContentPane().add(pot);
                    pot.addTab(" ADD NEW ...",pol1);
                    pot.addTab(" DISPLAY ...",pol2);
                    dpq1=new JLabel("Name of the Student :");
                    dpq2=new JLabel("Year :");
                    dpq3=new JLabel("Branch :");
                    dpq4=new JLabel("Project Name :");
                    dpq5=new JLabel("Abstract :");
                    gpq1=new JTextField(20);
                    gpq2=new JTextField(4);
                    gpq3=new JTextField(20);
                    gpq4=new JTextField(20);
                    gpq5=new JTextField(900);
                    zpq1=new JButton("SUBMIT");
                    zpq2=new JButton("CANCEL");
                    zpq3=new JButton("DISPLAY RECORDS");
                    pol1.add(dpq1);pol1.add(gpq1);
                    pol1.add(dpq2);pol1.add(gpq2);
                    pol1.add(dpq3);pol1.add(gpq3);
                    pol1.add(dpq4);pol1.add(gpq4);
                    pol1.add(dpq5);pol1.add(gpq5);
                    pol1.add(zpq1);pol1.add(zpq2);
                    pol2.add(zpq3);
                    rog.setSize(500,500);
                    rog.setVisible(true);
                    rog.repaint();
                     // HANDLES WHEN "CANCEL" BUTTON IS CLICKED
                     zpq2.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==zpq2)
                            {
                                rog.dispose();
                            }
                        }
                        });
     
                     zpq3.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==zpq3)
                            {
                                // object refrence of "report" is used
                                JFrame frm = new viewmajor();
                                   frm.setSize(600, 600);
                                   frm.setLocation(50,50);
                                   frm.setVisible(true);
     
                            }
                        }
                        });
     
                     // HANDLES WHEN "SUBMIT"  BUTTON OF RECRUIMENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    zpq1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==zpq1)
                            {
                            String value1=gpq1.getText();
                            String value2=gpq2.getText();
                            String value3=gpq3.getText();
                            String value4=gpq4.getText();
                            String value5=gpq5.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into major(name,year,branch,prjname,abstract) values(?,?,?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.setString(4,value4);
                                st.setString(5,value5);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(rog,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(rog,"Error in submitting data!");
                             }
                           }
                          }
                        });
                }
                catch(Exception exe){}
            }
        }
     
     
     
        // DISPLAY MINOR PROJECT RECORDS(MINOR PROJECT PROFILE) IN STUDENT PROFILE SECTION
     
        public class viewmajor extends JFrame
           {
                    PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,pnam,br,abs;
                    int yr;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from major";
                    public viewmajor()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   ps=con.prepareStatement(que);	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                yr = rs.getInt(2);
                                                br = rs.getString(3);
                                                pnam = rs.getString(4);
                                                abs = rs.getString(5);
                                                rows++;
                                         }
                                    data1=new Object[rows][5];
                                    Object[] Colheads={"name","year","branch","project name","abstract"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
     
     
     
         // "MINOR PROJECT PROFILE " LAYOUT of "STUDENT PROFILE Section"
     
        public class minorpp extends JFrame
        {
            public minorpp()
            {
                try
                {
                    rtf = new JFrame("STUDENT DETAILS ....");
                    po1 = new JPanel();
                    po2 = new JPanel();
                    post = new JTabbedPane();
                    rtf.getContentPane().add(post);
                    post.addTab(" ADD NEW ...",po1);
                    post.addTab(" DISPLAY ...",po2);
                    dp1=new JLabel("Name of the Student :");
                    dp2=new JLabel("Year :");
                    dp3=new JLabel("Branch :");
                    dp4=new JLabel("Project Name :");
                    dp5=new JLabel("Abstract :");
                    gp1=new JTextField(20);
                    gp2=new JTextField(4);
                    gp3=new JTextField(20);
                    gp4=new JTextField(20);
                    gp5=new JTextField(900);
                    zp1=new JButton("SUBMIT");
                    zp2=new JButton("CANCEL");
                    zp3=new JButton("DISPLAY RECORDS");
                    po1.add(dp1);po1.add(gp1);
                    po1.add(dp2);po1.add(gp2);
                    po1.add(dp3);po1.add(gp3);
                    po1.add(dp4);po1.add(gp4);
                    po1.add(dp5);po1.add(gp5);
                    po1.add(zp1);po1.add(zp2);
                    po2.add(zp3);
                    rtf.setSize(500,500);
                    rtf.setVisible(true);
                    rtf.repaint();
                     // HANDLES WHEN "CANCEL" BUTTON IS CLICKED
                     zp2.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==zp2)
                            {
                                rtf.dispose();
                            }
                        }
                        });
     
                     zp3.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==zp3)
                            {
                                // object refrence of "report" is used
                                JFrame frm = new viewminor();
                                   frm.setSize(600, 600);
                                   frm.setLocation(50,50);
                                   frm.setVisible(true);
     
                            }
                        }
                        });
     
                     // HANDLES WHEN "SUBMIT"  BUTTON OF RECRUIMENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    zp1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==zp1)
                            {
                            String value1=gp1.getText();
                            String value2=gp2.getText();
                            String value3=gp3.getText();
                            String value4=gp4.getText();
                            String value5=gp5.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into minor(name,year,branch,prjname,abstract) values(?,?,?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.setString(4,value4);
                                st.setString(5,value5);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(rtf,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(rtf,"Error in submitting data!");
                             }
                           }
                          }
                        });
                }
                catch(Exception exe){}
            }
        }
     
     
     
        // DISPLAY MINOR PROJECT RECORDS(MINOR PROJECT PROFILE) IN STUDENT PROFILE SECTION
     
        public class viewminor extends JFrame
           {
                    PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,pnam,br,abs;
                    int yr;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from minor";
                    public viewminor()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   ps=con.prepareStatement(que);	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                yr = rs.getInt(2);
                                                br = rs.getString(3);
                                                pnam = rs.getString(4);
                                                abs = rs.getString(5);
                                                rows++;
                                         }
                                    data1=new Object[rows][5];
                                    Object[] Colheads={"name","year","branch","project name","abstract"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
     
        // "RECRUITMENT DETAIL" LAYOUT of Recruitment Section
     
        public class Recui extends JFrame
        {
            public Recui()
            {
                 try
                 {
                     pqr = new JFrame("RECRUITMENT DETAILS ....");
                     b1 = new JPanel();
                     b2 = new JPanel();
                     bqr = new JTabbedPane();
                     pqr.getContentPane().add(bqr);
                     bqr.addTab(" ADD NEW ...",b1);
                     bqr.addTab(" DISPLAY ...",b2);
                     ro1=new JLabel(" Name of the Company : ");
                     ro2=new JLabel(" No. of rounds conducted in interviews : ");
                     ro3=new JLabel(" Interview Question : ");
                     fi1=new JTextField(20);
                     fi2=new JTextField(2);
                     fi3=new JTextField(900);
                     sub1=new JButton("SUBMIT");
                     can1=new JButton("CANCEL");
                     dis1=new JButton("DISPLAY RECORDS");
                     b1.add(ro1);b1.add(fi1);
                     b1.add(ro2);b1.add(fi2);
                     b1.add(ro3);b1.add(fi3);
                     b1.add(sub1);b1.add(can1);// Adding Cancel Button
                     b2.add(dis1);
                     pqr.setSize(500,500);
                     pqr.setVisible(true);
                     pqr.repaint();
                     // HANDLES WHEN "CANCEL" BUTTON IS CLICKED
                     can1.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==can1)
                            {
                                pqr.dispose();
                            }
                        }
                        });
                     dis1.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==dis1)
                            {
                                // object refrence of "report" is used
                                JFrame frm1 = new review();
                                   frm1.setSize(600, 600);
                                   frm1.setLocation(50,50);
                                   frm1.setVisible(true);
     
                            }
                        }
                        });
     
                     // HANDLES WHEN "SUBMIT"  BUTTON OF RECRUIMENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    sub1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==sub1)
                            {
                            String value1=fi1.getText();
                            String value2=fi2.getText();
                            String value3=fi3.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into recruitment(name,rounds,question) values(?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(pqr,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(pqr,"Error in submitting data!");
                             }
                           }
                          }
                        });
     
                 }
                 catch(Exception ep){}
            }
        }
     
        // DIPLAY SECTION OF RECRUITMENT DETAIL(RECRUITMENT SECTION)
     
        public class review extends JFrame
          {
                    PreparedStatement ps;
                    Connection con;
                    ResultSet rs;
                    Statement st;
                    JLabel l1;
                    String nam,ques;
                    int round;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane scroller;
                    JTable table;
                    public review()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   st = con.createStatement ();	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=st.executeQuery("SELECT * from recruitment");
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                round = rs.getInt(2);
                                                ques = rs.getString(3);
                                                rows++;
                                         }
                                    data1=new Object[rows][3];
                                    Object[] Colheads={"name","rounds","question"};
                                    rs=st.executeQuery("Select * from recruitment");
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<3;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     JTable table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     JScrollPane jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                       }
                                try{
                                        data1=new Object[rows][3];
                                        Object[] Colheads={"name","rounds","question"};
                                        rs=st.executeQuery("Select * from recruitment");
                                        for(int i1=0;i1<rows;i1++)
                                            {
                                                 rs.next();
                                                 for(int j1=0;j1<3;j1++)
                                                     {
                                                             data1[i1][j1]=rs.getString(j1+1);
                                                     }
                                            }
                                        JTable table=new JTable(data1,Colheads);
                                        int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                        int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                        JScrollPane jsp=new JScrollPane(table,v,h);
                                        getContentPane().add(jsp);
     
                                   }
                                    catch(Exception e)
                                    {
                                    }
                        setVisible(true);
                         //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
          }
     
        // "STUDENT DETAIL" LAYOUT of Recruitment Section
     
        public class Auto extends JFrame
        {
            public Auto()
            {
                 try
                {
                    abc = new JFrame("STUDENT DETAILS ....");
                    a1 = new JPanel();
                    a2 = new JPanel();
                    bq = new JTabbedPane();
                    abc.getContentPane().add(bq);
                    bq.addTab(" ADD NEW ...",a1);
                    bq.addTab(" DISPLAY ...",a2);
                    jl2=new JLabel("Name of the Student :");
                    jl3=new JLabel("Year :");
                    jl4=new JLabel("Branch of the Student :");
                    jl5=new JLabel("Name of the Company :");
                    jl6=new JLabel("Package (in Rs) :");
                    jl7=new JLabel("Posting Location :");
                    jt2=new JTextField(25);
                    jt3=new JTextField(4);
                    jt4=new JTextField(20);
                    jt5=new JTextField(20);
                    jt6=new JTextField(12);
                    jt7=new JTextField(25);
                    jb2=new JButton("SUBMIT");
                    jb21=new JButton("CANCEL");
                    disp=new JButton("DISPLAY RECORDS");
                    a1.add(jl2);a1.add(jt2);
                    a1.add(jl3);a1.add(jt3);
                    a1.add(jl4);a1.add(jt4);
                    a1.add(jl5);a1.add(jt5);
                    a1.add(jl6);a1.add(jt6);
                    a1.add(jl7);a1.add(jt7);
                    a1.add(jb2);a1.add(jb21);a2.add(disp);
                    abc.setSize(500,500);
                    abc.setVisible(true);
                    abc.repaint();
                    jb21.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==jb21)
                            {
                                abc.dispose();
                            }
                        }
                        });
                    disp.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==disp)
                            {
                                // object refrence of "report" is used
                                JFrame frm6 = new report();
                                   frm6.setSize(600, 600);
                                   frm6.setLocation(50,50);
                                   frm6.setVisible(true);
     
                            }
                        }
                        });
                    // HANDLES WHEN "SUBMIT"  BUTTON OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    jb2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==jb2)
                            {
                            String value1=jt2.getText();
                            String value2=jt3.getText();
                            String value3=jt4.getText();
                            String value4=jt5.getText();
                            String value5=jt6.getText();
                            String value6=jt7.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into recstudent(name,year,branch,company,package,location) values(?,?,?,?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.setString(4,value4);
                                st.setString(5,value5);
                                st.setString(6,value6);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(abc,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(abc,"Error in submitting data!");
                             }
                           }
                          }
                        });
                  }
                catch(Exception exe){}
            }
        }
     
        // DISPLAY SECTION OF STUDENT DETAIL(RECRUITMENT SECTION) 
            public class report extends JFrame
                {
                    PreparedStatement ps;
                    Connection con;
                    ResultSet rs;
                    Statement st;
                    JLabel l1;
                    String nam,brn,com,loc;
                    int yr,pac;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane scroller;
                    JTable table;
                    public report()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   st = con.createStatement ();	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=st.executeQuery("SELECT * from recstudent");
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                yr = rs.getInt(2);
                                                brn = rs.getString(3);
                                                com = rs.getString(4);
                                                pac = rs.getInt(5);
                                                loc = rs.getString(6);
                                                rows++;
                                         }
                                    data1=new Object[rows][6];
                                    Object[] Colheads={"name","year","branch","company","package","location"};
                                    rs=st.executeQuery("Select * from recstudent");
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<6;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     JTable table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     JScrollPane jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                       }
                                try{
                                        data1=new Object[rows][6];
                                        Object[] Colheads={"name","year","branch","company","package","location"};
                                        rs=st.executeQuery("Select * from recstudent");
                                        for(int i1=0;i1<rows;i1++)
                                            {
                                                 rs.next();
                                                 for(int j1=0;j1<8;j1++)
                                                     {
                                                             data1[i1][j1]=rs.getString(j1+1);
                                                     }
                                            }
                                        JTable table=new JTable(data1,Colheads);
                                        int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                        int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                        JScrollPane jsp=new JScrollPane(table,v,h);
                                        getContentPane().add(jsp);
     
                                   }
                                    catch(Exception e)
                                    {
                                    }
                        setVisible(true);
                         //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
                }
     
        // "STUDENT DETAIL" LAYOUT of "STUDENT PROFILE Section"
     
        public class Student extends JFrame
        {
            public Student()
            {
                try
                {
                    abq = new JFrame("STUDENT DETAILS ....");
                    ab1 = new JPanel();
                    ab2 = new JPanel();
                    adp = new JTabbedPane();
                    abq.getContentPane().add(adp);
                    adp.addTab(" ADD NEW ...",ab1);
                    adp.addTab(" DISPLAY ...",ab2);
                    pb1=new JLabel("Name of the Student :");
                    pb2=new JLabel("Guardian's Name :");
                    pb3=new JLabel("Registration Number :");
                    pb4=new JLabel("Branch :");
                    pb5=new JLabel("Year :");
                    pb6=new JLabel("Address :");
                    pb7=new JLabel("Phone Number :");
                    pb8=new JLabel("Semister Average :");
                    pb9=new JLabel("No. of Backlogs :");
                    pb10=new JLabel("Last Qualifiacation :");
                    pb11=new JLabel("Career Percentage :");
                    g1=new JTextField(20);
                    g2=new JTextField(20);
                    g3=new JTextField(10);
                    g4=new JTextField(20);
                    g5=new JTextField(4);
                    g6=new JTextField(40);
                    g7=new JTextField(11);
                    g8=new JTextField(3);
                    g9=new JTextField(3);
                    g10=new JTextField(25);
                    g11=new JTextField(2);
                    z1=new JButton("SUBMIT");
                    z2=new JButton("CANCEL");
                    z3=new JButton("DISPLAY RECORDS");
                    ab1.add(pb1);ab1.add(g1);
                    ab1.add(pb2);ab1.add(g2);
                    ab1.add(pb3);ab1.add(g3);
                    ab1.add(pb4);ab1.add(g4);
                    ab1.add(pb5);ab1.add(g5);
                    ab1.add(pb6);ab1.add(g6);
                    ab1.add(pb7);ab1.add(g7);
                    ab1.add(pb8);ab1.add(g8);
                    ab1.add(pb9);ab1.add(g9);
                    ab1.add(pb10);ab1.add(g10);                
                    ab1.add(pb11);ab1.add(g11);
                    ab1.add(z1);ab1.add(z2);
                    ab2.add(z3);
                    abq.setSize(500,500);
                    abq.setVisible(true);
                    abq.repaint();
                     // HANDLES WHEN "CANCEL" BUTTON IS CLICKED
                     z2.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            if(ae.getSource()==z2)
                            {
                                abq.dispose();
                            }
                        }
                        });
     
                     z3.addActionListener(new ActionListener(){
                        public void actionPerformed(ActionEvent ae)
                        {
                            // HANDLES WHEN "DISPLAY BUTTON" OF STUDENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                            if(ae.getSource()==z3)
                            {
                                // object refrence of "report" is used
                                JFrame frm = new viewstudent();
                                   frm.setSize(600, 600);
                                   frm.setLocation(50,50);
                                   frm.setVisible(true);
     
                            }
                        }
                        });
     
                     // HANDLES WHEN "SUBMIT"  BUTTON OF RECRUIMENT DETAIL(RECRUITMENT SECTION) IS CLICKED
                    z1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent ae){
                            if(ae.getSource()==z1)
                            {
                            String value1=g1.getText();
                            String value2=g2.getText();
                            String value3=g3.getText();
                            String value4=g4.getText();
                            String value5=g5.getText();
                            String value6=g6.getText();
                            String value7=g7.getText();
                            String value8=g8.getText();
                            String value9=g9.getText();
                            String value10=g10.getText();
                            String value11=g11.getText();
                            try{
                                Class.forName("oracle.jdbc.driver.OracleDriver");
                                Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                                PreparedStatement st=con.prepareStatement("insert into studentpro(name,gname,regno,branch,year,address,phno,avgsemmark,backlog,qualify,careerpercent) values(?,?,?,?,?,?,?,?,?,?,?)");
                                st.setString(1,value1);
                                st.setString(2,value2);
                                st.setString(3,value3);
                                st.setString(4,value4);
                                st.setString(5,value5);
                                st.setString(6,value6);
                                st.setString(7,value7);
                                st.setString(8,value8);
                                st.setString(9,value9);
                                st.setString(10,value10);
                                st.setString(11,value11);
                                st.executeUpdate();
                                JOptionPane.showMessageDialog(abq,"Data is successfully inserted into database.");
                                con.close();
                            }
                            catch(Exception e){
                                JOptionPane.showMessageDialog(abq,"Error in submitting data!");
                             }
                           }
                          }
                        });
                }
                catch(Exception exe){}
            }
        }
     
            // DISPLAY STUDENT RECORDS(STUDENT DETAILS) IN STUDENT PROFILE SECTION
     
        public class viewstudent extends JFrame
           {
               PreparedStatement ps;
                    Connection con;
                    ResultSet rs;
                    Statement st;
                    JLabel l1;
                    String nam,gnam,br,add,qual;
                    int yr,regno,phno,backl;
                    float avgsem,caer;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane scroller;
                    JTable table;
                    public viewstudent()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }catch(Exception e){}
                            try {
                                   st = con.createStatement ();	
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=st.executeQuery("SELECT * from studentpro");
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                gnam = rs.getString(2);
                                                regno = rs.getInt(3);
                                                br = rs.getString(4);
                                                yr = rs.getInt(5);
                                                add = rs.getString(6);
                                                phno = rs.getInt(7);
                                                avgsem = rs.getFloat(8);
                                                backl = rs.getInt(9);
                                                qual = rs.getString(10);
                                                caer = rs.getFloat(11);
                                                rows++;
                                         }
                                    data1=new Object[rows][11];
                                    Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                    rs=st.executeQuery("Select * from studentpro");
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     JTable table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     JScrollPane jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                       }
                                try{
                                        data1=new Object[rows][11];
                                        Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                        rs=st.executeQuery("Select * from studentpro");
                                        for(int i1=0;i1<rows;i1++)
                                            {
                                                 rs.next();
                                                 for(int j1=0;j1<11;j1++)
                                                     {
                                                             data1[i1][j1]=rs.getString(j1+1);
                                                     }
                                            }
                                        JTable table=new JTable(data1,Colheads);
                                        int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                        int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                        JScrollPane jsp=new JScrollPane(table,v,h);
                                        getContentPane().add(jsp);
     
                                   }
                                    catch(Exception e)
                                    {
                                    }
                        setVisible(true);
                         //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
            // DISPLAY STUDENT CAREER RECORDS WHEN "CAREER > 60" BUTTON OF CAREER SECTION IS CLICKED
     
     
        public class viewcar2 extends JFrame
           {
                    PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,gnam,br,add,qual;
                    int yr,regno,phno,backl;
                    float avgsem,caer;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from studentpro where careerpercent >= 60";
                    public viewcar2()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }
                            catch(Exception e)
                            {
                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                            }
                            try {
                                   ps=con.prepareStatement(que);
     
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                gnam = rs.getString(2);
                                                regno = rs.getInt(3);
                                                br = rs.getString(4);
                                                yr = rs.getInt(5);
                                                add = rs.getString(6);
                                                phno = rs.getInt(7);
                                                avgsem = rs.getFloat(8);
                                                backl = rs.getInt(9);
                                                qual = rs.getString(10);
                                                caer = rs.getFloat(11);
                                                rows++;
                                         }
                                    data1=new Object[rows][11];
                                    Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
     
        // DISPLAY STUDENT CAREER RECORDS WHEN "CAREER < 60" BUTTON OF CAREER SECTION IS CLICKED
     
     
        public class viewcar1 extends JFrame
           {
                    PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,gnam,br,add,qual;
                    int yr,regno,phno,backl;
                    float avgsem,caer;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from studentpro where careerpercent <= 60";
                    public viewcar1()
                     {
                        Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }
                            catch(Exception e)
                            {
                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                            }
                            try {
                                   ps=con.prepareStatement(que);
     
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                gnam = rs.getString(2);
                                                regno = rs.getInt(3);
                                                br = rs.getString(4);
                                                yr = rs.getInt(5);
                                                add = rs.getString(6);
                                                phno = rs.getInt(7);
                                                avgsem = rs.getFloat(8);
                                                backl = rs.getInt(9);
                                                qual = rs.getString(10);
                                                caer = rs.getFloat(11);
                                                rows++;
                                         }
                                    data1=new Object[rows][11];
                                    Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                      }
           }
     
     
        // DISPLAY STUDENT CAREER RECORDS WHEN "DISPLAY CAREER" BUTTON OF CAREER SECTION IS CLICKED
     
        public class viewcareer extends JFrame
           {
               PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,gnam,br,add,qual;
                    String value2 = tf2.getText();
                    int yr,regno,phno,backl;
                    float avgsem,caer;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from studentpro where careerpercent = ?";
                    public viewcareer()
                    {
                      Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }
                            catch(Exception e)
                            {
                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                            }
                            try {
                                   ps=con.prepareStatement(que);
                                   ps.setString(1,value2);
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                gnam = rs.getString(2);
                                                regno = rs.getInt(3);
                                                br = rs.getString(4);
                                                yr = rs.getInt(5);
                                                add = rs.getString(6);
                                                phno = rs.getInt(7);
                                                avgsem = rs.getFloat(8);
                                                backl = rs.getInt(9);
                                                qual = rs.getString(10);
                                                caer = rs.getFloat(11);
                                                rows++;
                                         }
                                    data1=new Object[rows][11];
                                    Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                    }
           }    
     
     
     
        // DISPLAY BACKLOG STUDENT RECORDS WHEN "DISPLAY" BUTTON OF BACKLOG SECTION IS CLICKED
     
        public class viewbackstudent extends JFrame
           {
               PreparedStatement ps;
                    Connection con = null;
                    ResultSet rs;
                    JLabel l1;
                    String nam,gnam,br,add,qual;
                    String value2 = tf1.getText();
                    int yr,regno,phno,backl;
                    float avgsem,caer;
                    int rows = 0;
                    Object data1[][];
                    JScrollPane jsp;
                    JTable table;
                    String que = "select * from studentpro where backlog = ?";
                    public viewbackstudent()
                    {
                      Container cp = getContentPane();
                        cp.setLayout(new BorderLayout());
                        setSize(600,600);
                        setLocation(50,50);
                        setLayout(new BorderLayout());
                        setTitle("Student Report");
                            try{
                                 Class.forName("oracle.jdbc.driver.OracleDriver");
                                 con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","password");
                               }
                            catch(Exception e)
                            {
                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                            }
                            try {
                                   ps=con.prepareStatement(que);
                                   ps.setString(1,value2);
                                   //Creating Statement Object.
                                }
                            catch (SQLException sqlex) {	//If Problem then Show the User a Message.
     
                                                            JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();	
     
                                                            //Closing the Form.
     
                                                        }
     
                            try{
                                    rs=ps.executeQuery();
                                    while(rs.next())
                                        {
                                                nam = rs.getString(1);
                                                gnam = rs.getString(2);
                                                regno = rs.getInt(3);
                                                br = rs.getString(4);
                                                yr = rs.getInt(5);
                                                add = rs.getString(6);
                                                phno = rs.getInt(7);
                                                avgsem = rs.getFloat(8);
                                                backl = rs.getInt(9);
                                                qual = rs.getString(10);
                                                caer = rs.getFloat(11);
                                                rows++;
                                         }
                                    data1=new Object[rows][11];
                                    Object[] Colheads={"name","gname","reg no","branch","year","address","phone number","semester mark","No. of backlogs","last qualification","career Average"};
                                    rs=ps.executeQuery();
                                    for(int i1=0;i1<rows;i1++)
                                        {
                                                rs.next();
                                                    for(int j1=0;j1<11;j1++)
                                                        {
                                                                data1[i1][j1]=rs.getString(j1+1);
                                                        }
                                        }
                                     table=new JTable(data1,Colheads);
                                     int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
                                     int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
                                     jsp=new JScrollPane(table,v,h);
                                     getContentPane().add(jsp);
     
                               }catch(Exception e)
                                       {
                                           JOptionPane.showMessageDialog (null, "A Problem Occurs While Loading Form.");
                                                            dispose ();
                                       }
     
                        setVisible(true);
                        //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
                    }
           }
     
        public void actionPerformed(ActionEvent e)
        {
            // HANDLES WHEN "STUDENT DETAIL" BUTTON OF RECRUITMENT SECTION IS CLICKED
            if(e.getSource()==stubtn)
            {
                Auto s=new Auto();
            }
            // HANDLES WHEN "RECUITMENT DETAIL" BUTTON OF RECUITMENT SECTION IS CLICKED
            else if(e.getSource()==req)
            {
                Recui qw = new Recui();
            }
     
            // HANDLES WHEN "STUDENT DETAIL" BUTTON OF STUDENT PROFILE SECTION IS CLICKED
            else if(e.getSource()==studentbtn)
            {
               Student so = new Student(); 
            }
     
            // HANDLES WHEN "DISPLAY" BUTTON OF BACKLOG SECTION IS CLICKED
            else if(e.getSource()==submitback)
            {
               viewbackstudent so = new viewbackstudent(); 
            }
     
            // HANDLES WHEN "DISPLAY CAREER" BUTTON OF CAREER SECTION IS CLICKED
            else if(e.getSource()==dispcareer)
            {
               viewcareer so = new viewcareer(); 
            }
     
     
            // HANDLES WHEN " CAREER > 60 " BUTTON OF CAREER SECTION IS CLICKED
            else if(e.getSource()==career1)
            {
               viewcar1 so = new viewcar1(); 
            }
     
            // HANDLES WHEN " CAREER < 60 " BUTTON OF CAREER SECTION IS CLICKED
            else if(e.getSource()==career2)
            {
               viewcar2 so = new viewcar2(); 
            }
     
            // HANDLES WHEN " MINOR PROJECT PROFILE " BUTTON OF STUDENT SECTION IS CLICKED
            else if(e.getSource()==miprojectbtn)
            {
               minorpp so = new minorpp(); 
            }
     
            // HANDLES WHEN " MAJOR PROJECT PROFILE " BUTTON OF STUDENT SECTION IS CLICKED
            else if(e.getSource()==maprojectbtn)
            {
               majorpp so = new majorpp(); 
            }
     
     
            // HANDLES WHEN " SEMINAR PROFILE " BUTTON OF STUDENT SECTION IS CLICKED
            else if(e.getSource()==seminarbtn)
            {
                seminar ab = new seminar();
            }
     
        }
     
        void dis()
                {
                    f.getContentPane().add(tp);
                    tp.addTab("STUDENT PROFILE SECTION",p1);
                    tp.addTab("CAREER LIST SECTION",p2);
                    tp.addTab("BACKLOG LIST SECTION",p3);
                    tp.addTab("STUDENT RECRUITMENT SECTION",p4);
                    f.setSize(720,280);
                    f.setVisible(true);
                    f.setResizable(true);
                }
     
        // MAIN FUNCTION IS HERE
        public static void main(String z[])
        {
            DatabaseRough pro=new DatabaseRough();
            pro.dis();
        }
    }

    I know it's a bit annoying to debug such a long program but i need to submit that project day after tomorrow.
    So any kind of help will be appreciated.

    Thanks & Regards !!!


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: My Code is not working [URGENT] Help Needed

    You would do well to post the entire error message and indicate where in the code the problems are occurring.

    Since the error is occurring intermittently, that suggests that you may be violating Swing's threading rules. Have you taken these into consideration when creating your code?

    --- Update ---

    Other suggestions:
    • You have created and have posted one huge God-Class, that is a large class that tries to do everything and then some. This will lead to several problems including making your code very hard to debug since you (and us) have to look through much code to understand what may be wrong. Much better would be for you to divide and conquer such that different parts of your program are in their own classes. This way you can test each sub-section of your code in isolation, which is much easier to do, and then if you run into a problem, you only need to post the much smaller involved class making things *much* easier for us.
    • Your variable naming is not good. Instead of variables with names like
      JButton zp1, zp2, zp3, zpg1, zpg2, zpg3, zpq1, ....
      and who can tell what this bit is doing?
                  ab1.add(pb3);
                  ab1.add(g3);
                  ab1.add(pb4);
                  ab1.add(g4);
                  ab1.add(pb5);
                  ab1.add(g5);
                  ab1.add(pb6);
                  ab1.add(g6);
                  ab1.add(pb7);
                  ab1.add(g7);
                  ab1.add(pb8);
                  ab1.add(g8);
                  ab1.add(pb9);
      You'd be far better off giving the variables names that make sense and explain what the variables do, or by using arrays or ArrayLists if you need collections of things. This will make your code self-commenting and much easier for us and for your "future" self to understand.


    --- Update ---

    Also, please consider improving your question title for this forum. Consider the thread title here as being similar to the headline of a newspaper article -- a brief statement that summarizes the essence of your problem in an informative way. Your title, "My Code is not working [URGENT] Help Needed" tells us nothing useful. We know you need help, else you wouldn't be posting here, and the "URGENT" part can upset some folks here. We're all volunteers and many don't like being and really shouldn't be pressured or rushed to answer. Also, your question is no more important than any other question here, and you shouldn't try to make it so as this is not fair to other's seeking help here.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: My Code is not working [URGENT] Help Needed

    Another observation on the code: TOO many empty catch blocks!!!
    You should ALWAYS call the printStackTrace() method in a catch block to get the full text of any errors that happened.
    If you don't understand my answer, don't ignore it, ask a question.

  4. The Following User Says Thank You to Norm For This Useful Post:

    curmudgeon (November 25th, 2012)

  5. #4
    Junior Member
    Join Date
    Nov 2012
    Posts
    14
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default Re: My Code is not working [URGENT] Help Needed

    Another thing....try using array of components instead of having 1,2,3,....
    if u use array, it reduces the code to very very much.
    u can use "for" loop while allocating memory,adding them to panel......

Similar Threads

  1. URGENT HELP NEEDED WITH ALGORITHM PLEASE! PLEASE! .... THANKS
    By Honours in forum Java Theory & Questions
    Replies: 6
    Last Post: March 13th, 2011, 08:40 PM
  2. urgent help needed
    By nono in forum Member Introductions
    Replies: 2
    Last Post: March 10th, 2011, 11:18 AM
  3. Urgent help needed
    By mohit1007 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 23rd, 2010, 09:34 PM
  4. Urgent Help needed with java codes
    By makarov in forum Java Theory & Questions
    Replies: 0
    Last Post: November 13th, 2009, 07:23 AM
  5. Urgent code needed
    By subhvi in forum AWT / Java Swing
    Replies: 4
    Last Post: August 27th, 2009, 12:55 AM