Null Exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kalvarahul
    New Member
    • Oct 2007
    • 3

    #1

    Null Exception

    I have implemented a code for one form its name is hardware form and first i will enter data it will take it and after enetering the second time it is gving me an null pointer exception it is not allowing me to update this form please can any one help me out.
    Regards,
    rahul.

    Code where it is giving error is (in editing):


    public String add_action() {

    RequestBean1 bean = getRequestBean1 ();
    String name= this.getProject _id().getText() .toString();

    CachedRowSetDat aProvider pro_allocDataPr ovider = bean.getProject _allocateDataPr ovider();

    try {

    if(pro_allocDat aProvider.getRo wCount()>0) {

    pro_allocDataPr ovider.cursorFi rst();
    do {

    if (pro_allocDataP rovider.getValu e("project_allo cate.project_id ").toString().e quals(name)) {
    System.out.prin tln(name);
    pro_allocDataPr ovider.setValue ("project_alloc ate.project_id" , this.getProject _id().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.project_nam e", this.getName(). getText().toStr ing() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.owner", this.getOwner() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.ISV", this.getISV_nam e().getText().t oString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.start_date" , this.getStart_d ate().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.end_date", this.getEnd_dat e().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.ptype", this.getProject _type().getSele cted().toString () );
    pro_allocDataPr ovider.setValue ("project_alloc ate.location", this.getLocatio n().getSelected ().toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.scope", this.getScope() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.isvvisit", this.getISV_vis it().getSelecte d().toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.network", this.getNetwork ().getSelected( ).toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.addition", this.getAdditio nal().getText() .toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.DBOS", this.getDbos(). getText().toStr ing() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.model", this.getModel() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.memory", this.getMemory( ).getText().toS tring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.cpu", this.getCpu().g etText().toStri ng() );
    //
    pro_allocDataPr ovider.commitCh anges();
    }

    } while (pro_allocDataP rovider.cursorN ext());

    }
    info ("Hardware details updated successfully.") ;
    return "case1";
    } catch (Exception ex) {
    log("Error Description", ex);
    error("Error :"+ex.getMessag e());
    }
    return null;
    }
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by kalvarahul
    I have implemented a code for one form its name is hardware form and first i will enter data it will take it and after enetering the second time it is gving me an null pointer exception it is not allowing me to update this form please can any one help me out.
    Regards,
    rahul.

    Code where it is giving error is (in editing):


    public String add_action() {

    RequestBean1 bean = getRequestBean1 ();
    String name= this.getProject _id().getText() .toString();

    CachedRowSetDat aProvider pro_allocDataPr ovider = bean.getProject _allocateDataPr ovider();

    try {

    if(pro_allocDat aProvider.getRo wCount()>0) {

    pro_allocDataPr ovider.cursorFi rst();
    do {

    if (pro_allocDataP rovider.getValu e("project_allo cate.project_id ").toString().e quals(name)) {
    System.out.prin tln(name);
    pro_allocDataPr ovider.setValue ("project_alloc ate.project_id" , this.getProject _id().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.project_nam e", this.getName(). getText().toStr ing() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.owner", this.getOwner() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.ISV", this.getISV_nam e().getText().t oString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.start_date" , this.getStart_d ate().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.end_date", this.getEnd_dat e().getText() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.ptype", this.getProject _type().getSele cted().toString () );
    pro_allocDataPr ovider.setValue ("project_alloc ate.location", this.getLocatio n().getSelected ().toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.scope", this.getScope() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.isvvisit", this.getISV_vis it().getSelecte d().toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.network", this.getNetwork ().getSelected( ).toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.addition", this.getAdditio nal().getText() .toString() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.DBOS", this.getDbos(). getText().toStr ing() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.model", this.getModel() .getText().toSt ring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.memory", this.getMemory( ).getText().toS tring() );
    pro_allocDataPr ovider.setValue ("project_alloc ate.cpu", this.getCpu().g etText().toStri ng() );
    //
    pro_allocDataPr ovider.commitCh anges();
    }

    } while (pro_allocDataP rovider.cursorN ext());

    }
    info ("Hardware details updated successfully.") ;
    return "case1";
    } catch (Exception ex) {
    log("Error Description", ex);
    error("Error :"+ex.getMessag e());
    }
    return null;
    }
    1.) Use code tags when posting code.
    2.) The exception stacktrace should tell you the exact line number where the exception was thrown.

    Comment

    • kalvarahul
      New Member
      • Oct 2007
      • 3

      #3
      Originally posted by r035198x
      1.) Use code tags when posting code.
      2.) The exception stacktrace should tell you the exact line number where the exception was thrown.




      sorry i will give you a comment at the location (it is in third line i have given comments)
      -----------------------------

      public String add_action() {

      RequestBean1 bean = getRequestBean1 ();
      String name= this.getProject _id().getText() .toString();// At this location it is pointing out error and the error is java.lang.NullP ointerException

      CachedRowSetDat aProvider pro_allocDataPr ovider = bean.getProject _allocateDataPr ovider();

      try {

      if(pro_allocDat aProvider.getRo wCount()>0) {

      pro_allocDataPr ovider.cursorFi rst();
      do {

      if (pro_allocDataP rovider.getValu e("project_allo cate.project_id ").toString().e quals(name)) {
      System.out.prin tln(name);
      pro_allocDataPr ovider.setValue ("project_alloc ate.project_id" , this.getProject _id().getText() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.project_nam e", this.getName(). getText().toStr ing() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.owner", this.getOwner() .getText().toSt ring() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.ISV", this.getISV_nam e().getText().t oString() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.start_date" , this.getStart_d ate().getText() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.end_date", this.getEnd_dat e().getText() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.ptype", this.getProject _type().getSele cted().toString () );
      pro_allocDataPr ovider.setValue ("project_alloc ate.location", this.getLocatio n().getSelected ().toString() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.scope", this.getScope() .getText().toSt ring() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.isvvisit", this.getISV_vis it().getSelecte d().toString() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.network", this.getNetwork ().getSelected( ).toString() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.addition", this.getAdditio nal().getText() .toString() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.DBOS", this.getDbos(). getText().toStr ing() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.model", this.getModel() .getText().toSt ring() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.memory", this.getMemory( ).getText().toS tring() );
      pro_allocDataPr ovider.setValue ("project_alloc ate.cpu", this.getCpu().g etText().toStri ng() );
      //
      pro_allocDataPr ovider.commitCh anges();
      }

      } while (pro_allocDataP rovider.cursorN ext());

      }
      info ("Hardware details updated successfully.") ;
      return "case1";
      } catch (Exception ex) {
      log("Error Description", ex);
      error("Error :"+ex.getMessag e());
      }
      return null;
      }

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by kalvarahul
        sorry i will give you a comment at the location (it is in third line i have given comments)
        -----------------------------

        public String add_action() {

        RequestBean1 bean = getRequestBean1 ();
        String name= this.getProject _id().getText() .toString();// At this location it is pointing out error and the error is java.lang.NullP ointerException

        CachedRowSetDat aProvider pro_allocDataPr ovider = bean.getProject _allocateDataPr ovider();

        try {

        if(pro_allocDat aProvider.getRo wCount()>0) {

        pro_allocDataPr ovider.cursorFi rst();
        do {

        if (pro_allocDataP rovider.getValu e("project_allo cate.project_id ").toString().e quals(name)) {
        System.out.prin tln(name);
        pro_allocDataPr ovider.setValue ("project_alloc ate.project_id" , this.getProject _id().getText() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.project_nam e", this.getName(). getText().toStr ing() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.owner", this.getOwner() .getText().toSt ring() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.ISV", this.getISV_nam e().getText().t oString() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.start_date" , this.getStart_d ate().getText() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.end_date", this.getEnd_dat e().getText() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.ptype", this.getProject _type().getSele cted().toString () );
        pro_allocDataPr ovider.setValue ("project_alloc ate.location", this.getLocatio n().getSelected ().toString() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.scope", this.getScope() .getText().toSt ring() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.isvvisit", this.getISV_vis it().getSelecte d().toString() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.network", this.getNetwork ().getSelected( ).toString() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.addition", this.getAdditio nal().getText() .toString() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.DBOS", this.getDbos(). getText().toStr ing() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.model", this.getModel() .getText().toSt ring() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.memory", this.getMemory( ).getText().toS tring() );
        pro_allocDataPr ovider.setValue ("project_alloc ate.cpu", this.getCpu().g etText().toStri ng() );
        //
        pro_allocDataPr ovider.commitCh anges();
        }

        } while (pro_allocDataP rovider.cursorN ext());

        }
        info ("Hardware details updated successfully.") ;
        return "case1";
        } catch (Exception ex) {
        log("Error Description", ex);
        error("Error :"+ex.getMessag e());
        }
        return null;
        }
        You forgot those code tags again.
        So now you have the culprit ...

        Comment

        Working...