我的记录未插入

时间:2017-05-23 09:31:28

标签: java swing oop 3-tier

这是我的表格代码,我在课堂上传递参数。 表单类

中出现此错误
  找不到合适的构造函数   cProperty以下(字符串,字符串,整数,INT,INT,INT,字符串,字符串,整数,字符串,字符串,字符串)       构造函数cProperty.cProperty(String,String,int,int,int,int,String,String,int,String,String,int)   不适用         (实际参数String不能通过方法调用转换转换为int)       构造函数cProperty.cProperty()不适用         (实际和正式的参数列表长度不同)

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         

       try
       {
           cProperty p1=new cProperty(this.tx1.getText(),this.tx2.getText(),Integer.parseInt(this.tx3.getText()),Integer.parseInt(this.tx4.getText()),Integer.parseInt(this.tx5.getText()),Integer.parseInt(this.tx6.getText()),this.tx7.getText(),((JTextField)jDCS.getDateEditor().getUiComponent()).getText(),Integer.parseInt(this.tx8.getText()),this.tx9.getText(),((JTextField)jDCB.getDateEditor().getUiComponent()).getText(),this.tx10.getText());
           if(p1.addProperty()>0)
            {
                JOptionPane.showMessageDialog(this,"Records inserted successfully"); 
            }
            else
            {
                JOptionPane.showMessageDialog(this,"Records not inserted");  
            } 


       }
       catch(Exception e){
           JOptionPane.showMessageDialog(null, e);
       }
    }

这是我的课程,我从表格中获取值

public class cProperty 
{
    String AREA;
    String LOCATION;
    int UNITS_OF_MEASUREMENT;
    int NATURE;
    int TYPE;
    int SELLER;
    String SELLER_PRICE;
    String SELLER_DATE;
    int BUYER;
    String BUYER_PRICE;
    String BUYER_DATE;
    int AGENT;


    public cProperty()
    {

    }

    public cProperty(String area,String location,int uom,int nature, int type, int seller, String sprice, String sdate, int buyer, String bprice, String bdate, int agent)
    {
    AREA=area;
    LOCATION=location;
    UNITS_OF_MEASUREMENT=uom;
    NATURE=nature;
    TYPE=type;
    SELLER=seller;
    SELLER_PRICE=sprice;
    SELLER_DATE=sdate;
    BUYER=buyer;
    BUYER_PRICE=bprice;
    BUYER_DATE=bdate;
    AGENT=agent;
    }

    public int addProperty()
    {
        try
        {
            cDBcon db1 =new cDBcon();
            String qry="Insert into PROPERTY(AREA,LOCATION,UNITS_OF_MEASUREMET,NATURE,TYPE,SELLER,SELLER_PRICE,SELLER_DATE,BUYER,BUYER_PRICE,BUYER_DATE,AGENT) VALUES ('"+AREA+"','"+LOCATION+"','"+UNITS_OF_MEASUREMENT+"','"+NATURE+"','"+TYPE+"','"+SELLER+"','"+SELLER_PRICE+"','"+SELLER_DATE+"','"+BUYER+"','"+BUYER_PRICE+"','"+AGENT+"')";

             return db1.UDI(qry);            
        }

        catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, e);
        }
        return 0;
    }

1 个答案:

答案 0 :(得分:0)

  

实际参数String不能通过方法调用转换为int   转化

this.tx10.getText()属于String类型,应将其转换为int

尝试

Integer.parseInt(this.tx10.getText())

代替

this.tx8.getText()