如何解决“第1行”列'type_id'的错误“整数值:'null'错误?”

问题描述 投票:0回答:1
Statement s_add_purchase_wedding= conn.createStatement();
String sql_add_purchase_wedding = "INSERT INTO bidservice(token_id,added_id,purchase_id,service_type,type_id,bid_amount,forward_status,confirmation)VALUES"
        + "('"+url_id+"','"+added_id+"','"+purchase_id+"','"+pur_wed.getTypeWedding()+"',1,'"+pur_wed.getAmount()+"','"+pur_wed.getForwardAdmin()+"'"
        + ",'"+pur_wed.getConfirmation()+"')";

s_add_purchase_wedding.executeUpdate(sql_add_purchase_wedding);

我已经宣布了url_idadded_id和`puchase_id并为它们分配值。

java mysql jsp servlets
1个回答
0
投票

您的错误在于将Integer(1)插入表中(+“',1,'”)。插入Integer的最佳方法是(“',”+ 1 +“,”)。

你这样做的时候怎么样?

String sql_add_purchase_wedding = "INSERT INTO bidservice(token_id, added_id, purchase_id, service_type, type_id, bid_amount, forward_status, confirmation) VALUES ("+
                    "'"+ url_id+"',"+
                    "'"+ added_id+"',"+
                    "'"+ purchase_id+"',"+
                    "'"+ pur_wed.getTypeWedding() +"',"+
                    1 +","+
                    "'"+ pur_wed.getAmount()+"',"+
                    "'"+ pur_wed.getForwardAdmin()+"',"+
                    "'"+ pur_wed.getConfirmation()+"'"+
                ")";

s_add_purchase_wedding.executeUpdate(sql_add_purchase_wedding);
© www.soinside.com 2019 - 2024. All rights reserved.