如何使用gui使用netbeans更新我的表?

时间:2016-11-06 17:00:27

标签: java mysql

代码:

private void updateActionPerformed(java.awt.event.ActionEvent evt) {                                       
    // TODO add your handling code here:

    try{
        PreparedStatement pstmt = con.prepareStatement("update tender.bidder set bname =?,office=?,street=?,city=?,state=?,contact_no=?,password=?,email=?,t_id=? where b_id = ?");

           // String sql = "update tender.bidder set bname ='"+bnametxt.getText()+"'"+",office ='"+officetxt.getText()+"'"+
           //         ",street ='"+streettxt.getText()+"'"+",contact_no='"+contacttxt.getText()+"'"+",password='"+passwordtxt.getText()+"'"+",email='"+emailtxt.getText()
           //         +"'"+"where b_id ="+bidtxt.getText();
        pstmt.setString(1,bidtxt.getText());
        pstmt.setString(2,bnametxt.getText());
        pstmt.setString(3,officetxt.getText());
        pstmt.setString(4,streettxt.getText());
        pstmt.setString(5,citytxt.getText());
        pstmt.setString(6,statetxt.getText());
        pstmt.setString(7,contacttxt.getText());
        pstmt.setString(8,passwordtxt.getText());
        pstmt.setString(9,emailtxt.getText());
        pstmt.setString(10,tidtxt.getText());
        int i = pstmt.executeUpdate();
        Statement s = con.createStatement();
        s.executeUpdate("update tender.bidder set bname ='"+bnametxt.getText()+"'"+",office='"+officetxt.getText()+"'"+",street='"+streettxt.getText()+"'"+",city='"+citytxt.getText()+"'"+",state='"+statetxt.getText()+"'"+",contact_no='"+contacttxt.getText()+"'"+",password='"+passwordtxt.getText()+"'"+",email="+emailtxt.getText()+"'"+",t_id="+tidtxt.getText()+"'"+"where b_id ="+bidtxt.getText());
                 //   +streettxt.getText()+"'"+",city='"+citytxt.getText()+"'"+",state='"+statetxt.getText()+"'"+",contact_no='"+contacttxt.getText()+"'"+",password="+"'"passwordtxt.getText()
                 //   +"'"+",email="+emailtxt.getText()+"'"+",t_id='"+tidtxt.getText() +"'"+"where b_id ="+bidtxt.getText();
           // Statement updt = (Statement) con.createStatement();
        System.out.println(i+"record updated");
        con.close();
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
        selectionall();

}   

错误:

  

java.sql.SQLSyntaxErrorException:列'B002'要么不在FROM列表中的任何表中,要么出现在连接规范中,并且不在连接规范的范围内,或者出现在HAVING子句中,并且不在GROUP中按列表。如果这是CREATE或ALTER TABLE语句,则“B002”不是目标表中的列。

0 个答案:

没有答案