public boolean addGoods(ShopShow shopshow) {
boolean flag = false;
try {
String sql="insert into goodscar(id,name,dustry,price,number) values('"+shopshow.getId()+"','"+shopshow.getName()+"','"+shopshow.getDustry()+"','"+shopshow.getPrice()+"','"+shopshow.getNumber()+"');";
PreparedStatement pstmt = conn.prepareStatement(sql);
int i = pstmt.executeUpdate();
pstmt.close();
conn.close();
if(i>0) {
flag = true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return flag;
INSERT INTO goodscar VALUES('2','小米2','三小只','11','1');我打了断点获取了sql的值粘贴到数据库中运行时是可以插入数据的。但是在javaEE中运行flag返回值是false。这让我百思不得其解