NullpointerException

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pradeep84
    New Member
    • Sep 2007
    • 37

    #1

    NullpointerException

    Exception in thread "AWT-EventQueue-0" java.lang.NullP ointerException
    wat does it mean...
    how to debug this runtime error..
    Help me.. plz....

    Regards
    pradeep
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by pradeep84
    Exception in thread "AWT-EventQueue-0" java.lang.NullP ointerException
    wat does it mean...
    how to debug this runtime error..
    Help me.. plz....

    Regards
    pradeep
    A NullPointerExce ption means, that it can't find something, that should be there. However, without the code, which throws this Exception, we'll hardly be able to help you.

    Greetings,
    nepomuk

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Do not flood the forum with the same question.
      NullPointerExce ption means that you derefenced a null value. One of your variables was pointing to the null reference (nothing) and you dereferenced it.

      Comment

      • pradeep84
        New Member
        • Sep 2007
        • 37

        #4
        hi ...
        this is the program .. where i got runtime error.., can u say me where i hav done a mistake....

        import java.applet.*;
        import java.awt.*;
        import java.sql.*;
        import java.awt.event. *;
        import sun.jdbc.odbc.* ;
        public class SPlanting extends Frame implements ActionListener
        {
        TextField date,nom,tb,tl, st,ft,pc,on;
        Label l1,l2,l3,l4,l5, l6,l7,l8;
        Button save,exit;
        Connection con;
        ResultSet rs;
        Statement stmt;
        String s1,s2,s8;
        int s3,s4,s5,s6,s7;
        public SPlanting()
        {
        super("SPlantin g ");
        setSize(800,800 );
        setLayout(new GridLayout(7,2, 45,45));
        l1=new Label("Date");
        l2=new Label("Noofmixe s");
        l3=new Label("TotalBen tomikused");
        l4=new Label("TotalLus formused");
        l5=new Label("starttim e");
        l6=new Label("Offtime" );
        l7=new Label("PowerCon sumed");
        l8=new Label("Opertorn ame");


        add(l1);
        add(date);
        add(l2);
        add(nom);
        add(l3);
        add(tb);
        add(l4);
        add(tl);
        add(l5);
        add(st);
        add(l6);
        add(ft);
        add(l7);
        add(pc);
        add(l8);
        add(on);

        save.addActionL istener(this);
        exit.addActionL istener(this);
        setVisible(true );

        try
        {
        Class.forName(" sun.jdbc.odbc.J dbc.OdbcDriver" );
        con=DriverManag er.getConnectio n("jdbc.odbc.pr ism");
        stmt=con.create Statement();
        rs=stmt.execute Query("select * from SPlanting ");
        }
        catch(ClassNotF oundException e)
        {
        System.out.prin tln(e);
        }
        catch(SQLExcept ion e)
        {
        System.out.prin tln(e);
        }
        addWindowListen er(new WindowAdapter() {
        public void WindowClosing(W indowEvent w) {System.exit(0) ;}});
        }
        public void actionPerformed (ActionEvent ae)
        {
        if(ae.getSource ()==save)
        {
        s1=date.getText ();
        s2=nom.getText( );
        s3=Integer.pars eInt(tb.getText ());
        s4=Integer.pars eInt(tl.getText ());
        s5=Integer.pars eInt(st.getText ());
        s6=Integer.pars eInt(ft.getText ());
        s7=Integer.pars eInt(pc.getText ());
        s8=on.getText() ;
        try
        {
        String query ="insert into SPlanting(Date, Noofmixes,Total Bentomikused,To talLusformused, starttime,Offti me,PowerConsume d,Opertorname,O fftime,Shortage ,Cycles/day)"+ "values('"+s1+" ','"+s2+"','"+s 3+"','"+s4+"',' "+s5+"','"+s6+" ','"+s7+"','"+s 8+"')";
        Class.forName(" sun.jdbc.odbc.J dbc.OdbcDriver" );
        con=DriverManag er.getConnectio n("jdbc:odbc:pr ism");
        stmt=con.create Statement();
        rs=stmt.execute Query(query);
        stmt.close();
        }
        catch(ClassNotF oundException e)
        {
        System.out.prin tln(e);
        }
        catch(SQLExcept ion e)
        {
        System.out.prin tln(e);
        }
        }
        if(ae.getSource ()==exit)
        {
        System.exit(0);
        }
        }
        public static void main(String args[])
        {
        SPlanting sp=new SPlanting();
        }
        }


        regards
        pradeep

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by pradeep84
          hi ...
          this is the program .. where i got runtime error.., can u say me where i hav done a mistake....

          import java.applet.*;
          import java.awt.*;
          import java.sql.*;
          import java.awt.event. *;
          import sun.jdbc.odbc.* ;
          public class SPlanting extends Frame implements ActionListener
          {
          TextField date,nom,tb,tl, st,ft,pc,on;
          Label l1,l2,l3,l4,l5, l6,l7,l8;
          Button save,exit;
          Connection con;
          ResultSet rs;
          Statement stmt;
          String s1,s2,s8;
          int s3,s4,s5,s6,s7;
          public SPlanting()
          {
          super("SPlantin g ");
          setSize(800,800 );
          setLayout(new GridLayout(7,2, 45,45));
          l1=new Label("Date");
          l2=new Label("Noofmixe s");
          l3=new Label("TotalBen tomikused");
          l4=new Label("TotalLus formused");
          l5=new Label("starttim e");
          l6=new Label("Offtime" );
          l7=new Label("PowerCon sumed");
          l8=new Label("Opertorn ame");


          add(l1);
          add(date);
          add(l2);
          add(nom);
          add(l3);
          add(tb);
          add(l4);
          add(tl);
          add(l5);
          add(st);
          add(l6);
          add(ft);
          add(l7);
          add(pc);
          add(l8);
          add(on);

          save.addActionL istener(this);
          exit.addActionL istener(this);
          setVisible(true );

          try
          {
          Class.forName(" sun.jdbc.odbc.J dbc.OdbcDriver" );
          con=DriverManag er.getConnectio n("jdbc.odbc.pr ism");
          stmt=con.create Statement();
          rs=stmt.execute Query("select * from SPlanting ");
          }
          catch(ClassNotF oundException e)
          {
          System.out.prin tln(e);
          }
          catch(SQLExcept ion e)
          {
          System.out.prin tln(e);
          }
          addWindowListen er(new WindowAdapter() {
          public void WindowClosing(W indowEvent w) {System.exit(0) ;}});
          }
          public void actionPerformed (ActionEvent ae)
          {
          if(ae.getSource ()==save)
          {
          s1=date.getText ();
          s2=nom.getText( );
          s3=Integer.pars eInt(tb.getText ());
          s4=Integer.pars eInt(tl.getText ());
          s5=Integer.pars eInt(st.getText ());
          s6=Integer.pars eInt(ft.getText ());
          s7=Integer.pars eInt(pc.getText ());
          s8=on.getText() ;
          try
          {
          String query ="insert into SPlanting(Date, Noofmixes,Total Bentomikused,To talLusformused, starttime,Offti me,PowerConsume d,Opertorname,O fftime,Shortage ,Cycles/day)"+ "values('"+s1+" ','"+s2+"','"+s 3+"','"+s4+"',' "+s5+"','"+s6+" ','"+s7+"','"+s 8+"')";
          Class.forName(" sun.jdbc.odbc.J dbc.OdbcDriver" );
          con=DriverManag er.getConnectio n("jdbc:odbc:pr ism");
          stmt=con.create Statement();
          rs=stmt.execute Query(query);
          stmt.close();
          }
          catch(ClassNotF oundException e)
          {
          System.out.prin tln(e);
          }
          catch(SQLExcept ion e)
          {
          System.out.prin tln(e);
          }
          }
          if(ae.getSource ()==exit)
          {
          System.exit(0);
          }
          }
          public static void main(String args[])
          {
          SPlanting sp=new SPlanting();
          }
          }


          regards
          pradeep
          This is the second time I'm telling you to use code tags when posting code. (that's not a good thing on your part).
          Keep this problem in this original thread. Double posting is also against site rules.

          This thread will now be closed.

          Comment

          Working...