当前位置:编程学习 > JAVA >>

The method getItemNo() is undefined for the type Item怎么解决!!

The method getItemNo() is undefined for the type Item怎么解决
public class ItemDao4OracleImpl implements ItemDao {

public void addItem(Connection conn, Item item) {
    String sql="insert into t_items(item_no,itme_category_id,item_unit_id,item_name,spec,pattern)";
    sql+=" values(?,?,?,?,?,?)";
    PreparedStatement pstmt= null;
 try{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, item.getItemNo());
pstmt.setString(2, item.getItemName());
pstmt.setString(3, item.getSpec());
pstmt.setString(4, item.getPattern());
pstmt.setString(5, item.getItemCategory().getId());
pstmt.setString(6, item.getItemUnit().getId());
为什么显示:The method getItemNo() is undefined for the type Item?
Item 类里我已经定义了:
private String itemNo;
private String itemName;
private String spec;
private String pttern;
private ItemCategory itemCategory;
private ItemUnit itemUnit; --------------------编程问答-------------------- 说的很明白了Item类中没有定义
getItemNo()方法,虽然类中有itemNo字段
你却没有编写getItemNo()方法

--------------------编程问答-------------------- 我定义了get和set方法了,pstmt.setString(1, item.getItemNo());我这样调用是说没有定义了!!! 求解答! --------------------编程问答-------------------- 提示已经很明显了  --------------------编程问答-------------------- 编译都不通过吧 --------------------编程问答--------------------
引用 3 楼 liuyuhua0066 的回复:
提示已经很明显了 
 我定义了set和get方法了? --------------------编程问答--------------------
引用 5 楼 mark000b 的回复:
Quote: 引用 3 楼 liuyuhua0066 的回复:

提示已经很明显了 
 我定义了set和get方法了?
还是不行了? --------------------编程问答--------------------
引用 4 楼 xxhhbb1538 的回复:
编译都不通过吧
 恩是啊提示:The method getItemNo() is undefined for the type Item --------------------编程问答-------------------- 把你的item类贴出来 --------------------编程问答-------------------- 文本编辑器里面敲的代码吧。。。。
名字坑爹是敲错了,看看是不是大小写原因,或者干脆把item里的方法复制过来试试吧。。。。 --------------------编程问答-------------------- 求解决方法!! --------------------编程问答--------------------
引用 8 楼 yousteely 的回复:
把你的item类贴出来



package com.bjpowernode.drp.basedata.domain;

import com.bjpowernode.drp.util.datadict.domain.ItemCategory;
import com.bjpowernode.drp.util.datadict.domain.ItemUnit;

/**
 * 物料实体类
 * @author lenovo
 *
 */
public class Item {
private String itemNo;
private String itemName;
private String spec;
private String pttern;
//g关联物料类别ItemCategory
private ItemCategory itemCategory;
private ItemUnit itemUnit;
public String getItemNo() {
return itemNo;
}
public void setItemNo(String itemNo) {
this.itemNo = itemNo;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getPttern() {
return pttern;
}
public void setPttern(String pttern) {
this.pttern = pttern;
}
public ItemCategory getItemCategory() {
return itemCategory;
}
public void setItemCategory(ItemCategory itemCategory) {
this.itemCategory = itemCategory;
}
public ItemUnit getItemUnit() {
return itemUnit;
}
public void setItemUnit(ItemUnit itemUnit) {
this.itemUnit = itemUnit;
}


}
--------------------编程问答--------------------
引用 11 楼 mark000b 的回复:
Quote: 引用 8 楼 yousteely 的回复:

把你的item类贴出来



package com.bjpowernode.drp.basedata.domain;

import com.bjpowernode.drp.util.datadict.domain.ItemCategory;
import com.bjpowernode.drp.util.datadict.domain.ItemUnit;

/**
 * 物料实体类
 * @author lenovo
 *
 */
public class Item {
private String itemNo;
private String itemName;
private String spec;
private String pttern;
//g关联物料类别ItemCategory
private ItemCategory itemCategory;
private ItemUnit itemUnit;
public String getItemNo() {
return itemNo;
}
public void setItemNo(String itemNo) {
this.itemNo = itemNo;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getSpec() {
return spec;
}
public void setSpec(String spec) {
this.spec = spec;
}
public String getPttern() {
return pttern;
}
public void setPttern(String pttern) {
this.pttern = pttern;
}
public ItemCategory getItemCategory() {
return itemCategory;
}
public void setItemCategory(ItemCategory itemCategory) {
this.itemCategory = itemCategory;
}
public ItemUnit getItemUnit() {
return itemUnit;
}
public void setItemUnit(ItemUnit itemUnit) {
this.itemUnit = itemUnit;
}


}

-----------------------------------------------------------------------------------------

package com.bjpowernode.drp.basedata.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.bjpowernode.drp.util.ApplicationException;
import com.bjpowernode.drp.util.DbUtil;
import com.bjpowernode.drp.util.PageModel;
import com.sun.mail.imap.protocol.Item;

public class ItemDao4OracleImpl implements ItemDao {

public void addItem(Connection conn, Item item) {
    String sql="insert into t_items(item_no,itme_category_id,item_unit_id,item_name,spec,pattern)";
    sql+=" values(?,?,?,?,?,?)";
    PreparedStatement pstmt= null;
 try{
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, item.getItemNo());
pstmt.setString(2, item.getItemName());
pstmt.setString(3, item.getSpec());
pstmt.setString(4, item.getPattern());
pstmt.setString(5, item.getItemCategory().getId());
pstmt.setString(6, item.getItemUnit().getId());
pstmt.executeUpdate();
 }catch(SQLException e){
 e.printStackTrace();
 throw new ApplicationException("添加物料失败!");
 }finally{
DbUtil.close(pstmt);
 }
 
}

public void delItem(Connection conn, String[] itemNos) {
// TODO Auto-generated method stub

}

public Item findItemById(Connection conn, String itemNo) {
// TODO Auto-generated method stub
return null;
}

public PageModel findItemList(Connection conn,int pageNo, int pageSize, String condation) {
// TODO Auto-generated method stub
return null;
}

public void modifyItem(Connection conn, Item item) {
// TODO Auto-generated method stub

}

}
--------------------编程问答-------------------- import com.sun.mail.imap.protocol.Item;

!!!!!! --------------------编程问答-------------------- --------------------编程问答--------------------
引用 13 楼 liuyuhua0066 的回复:
import com.sun.mail.imap.protocol.Item;

!!!!!!
搞定谢谢!!!
补充:Java ,  Java SE
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,