Java setter方法异常为java.lang.NullPointerException

时间:2017-08-18 11:25:59

标签: java servlets

这是我的Mapping_manager.java文件代码。

resultSet = statement.executeQuery("SELECT * FROM mappingspecs where MappingCode=1 and Table_Name='value'; ");

                if (resultSet != null) {
                    Mappingspecs mappingspecs=null;
                    mappingspecslist=new ArrayList<Mappingspecs>();
                    while (resultSet.next()) { 
                         index=0;
                         field=resultSet.getString(4);
                         System.out.println("field--"+field);
                         mappingspecs.setZillow_Field_Name(resultSet.getString(4)==""?"null":resultSet.getString(4)); 
                    mappingspecslist.add(mappingspecs);

                    }
                }

我的映射getter和setter类

public class Mappingspecs {
    private int Index;
    private int mappingcode;
    private String Zillow_Table_Name;
    private String Zillow_Field_Name;
    private String Source_Table_Name;

    private int Source_Data_Field_No;
    private String Source_Data_Field_Name;
    private int Zillow_Field_Number;
    private String ZG_Conversion_Logic;


    public void Mappingspecs(int Index,int mappingcode,String Zillow_Table_Name,
            String Zillow_Field_Name,String Source_Table_Name,
            String Source_Data_Field_Name,int Source_Data_Field_No,
            int Zillow_Field_Number,String ZG_Conversion_Logic){
        this.Index=Index;
        this.mappingcode=mappingcode;
        this.Zillow_Table_Name=Zillow_Table_Name;
        this.Zillow_Field_Name="";
        this.Source_Table_Name=Source_Table_Name;
        this.Source_Data_Field_Name=Source_Data_Field_Name;
        this.Source_Data_Field_No=Source_Data_Field_No;
        this.Zillow_Field_Number=Zillow_Field_Number;
        this.ZG_Conversion_Logic=ZG_Conversion_Logic;
    }



    public int getMappingcode() {
        return mappingcode;
    }

    public void setMappingcode(int mappingcode) {
        this.mappingcode = mappingcode;
    }





    public int getIndex() {
        return Index;
    }

    public void setIndex(int index) {
        this.Index = index;
    }

    public String getSource_Table_Name() {
        return Source_Table_Name;
    }

    public void setSource_Table_Name(String source_Table_Name) {
        this.Source_Table_Name = source_Table_Name;
    }

    public String getSource_Data_Field_Name() {
        return Source_Data_Field_Name;
    }

    public void setSource_Data_Field_Name(String source_Data_Field_Name) {
        this.Source_Data_Field_Name = source_Data_Field_Name;
    }

    public int getSource_Data_Field_No() {
        return Source_Data_Field_No;
    }

    public void setSource_Data_Field_No(int source_Data_Field_No) {
        this.Source_Data_Field_No = source_Data_Field_No;
    }

    public String getZillow_Field_Name() {
        return Zillow_Field_Name;
    }

    public void setZillow_Field_Name(String zillow_Field_Name) {
        this.Zillow_Field_Name = zillow_Field_Name;
    }

    public String getZillow_Table_Name() {
        return Zillow_Table_Name;
    }

    public void setZillow_Table_Name(String zillow_Table_Name) {
        this.Zillow_Table_Name = zillow_Table_Name;
    }



    public String getZG_Conversion_Logic() {
        return ZG_Conversion_Logic;
    }

    public void setZG_Conversion_Logic(String zG_Conversion_Logic) {
        this.ZG_Conversion_Logic = zG_Conversion_Logic;
    }



    public int getZillow_Field_Number() {
        return Zillow_Field_Number;
    }

    public void setZillow_Field_Number(int zillow_Field_Number) {
        this.Zillow_Field_Number = zillow_Field_Number;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        Mappingspecs other = (Mappingspecs) obj;
        if (Index != other.Index)
            return false;
        return true;
    }




}
  

在运行代码时,我收到错误   mappingspecs.setZillow_Field_Name(resultSet.getString(4)== “空”, “?”:resultSet.getString(4));

     

这一行。我google了很多,但我无法找到问题。请弄清楚我在做错误的地方?

0 个答案:

没有答案