错误提示是这样的哈 java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Serval] INSERT statement conflicted with COLUMN CHECK constraint 'CK_Recipient_cZipC_1CF15040'. The conflict occurred in database 'ToyUniverse', table 'Recipient', column 'cZipCode'.
好好看一下PreparedStatement stat=con.prepareStatement("insert into Recipient(cOrderNo,vFirstName,vLastName,vAddress,cCity,cState,cCountryId,cZipCode,cPhone) values(?,?,?,?,?,?,?,?,?)");,插入的数据[cZipCode]不符合规范
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver][SQL Serval] INSERT statement conflicted with COLUMN CHECK constraint 'CK_Recipient_cZipC_1CF15040'. The conflict occurred in database 'ToyUniverse', table 'Recipient', column 'cZipCode'.
这个字段cZipCode的类型,你看看你定义的是char还是int应该那个错误说明的确是说你的类型不匹配
是不是你定义了一个int型,不过却在语句中用了一个“abc”这样的
非数字啊?你把你的那句insert语句打印出来看看
比如:Recipient中的cZipCode和A表中的cZipCode相关联,并且Recipient中的cZipCode字段值是来自于A表中的cZipCode字段的值,现要在Recipient中的cZipCode字段中插入'003',而A表中的cZipCode字段的值却没有'003',这种情况下你的错误出来了
谢谢淋东兄
和xkp兄