81,095
社区成员
发帖
与我相关
我的任务
分享
String isExist ="select BarCode from Pos where BarCode ='"+b+"';";
String isExisu ="select BarCode from Tos where BarCode ='"+b+"';";
PreparedStatement pstmt = conn.prepareStatement(isExist);
PreparedStatement pstmu = conn2.prepareStatement(isExisu);
ResultSet rs = pstmt.executeQuery();
ResultSet ru = pstmu.executeQuery();
if(rs.next()&&ru.next())
{
out.println("<script>alert('已存在数据');window.location.href='insert.html';</script>");
}
else if (rs.next())
{
stat.executeUpdate(INSERT INTO TOS (BarCode,) VALUES ('"+b+"'));
}
else if (ru.next())
{
stat.executeUpdate(INSERT INTO POS (BarCode,) VALUES ('"+b+"'));
}
else
{
stat.executeUpdate(INSERT INTO TOS (BarCode,) VALUES ('"+b+"'));
stat.executeUpdate(INSERT INTO POS (BarCode,) VALUES ('"+b+"'));
}
我不是专业学过编程的,目前的JSP文件都是我搜索回来然后修改而成的。技术有限。因为不是什么大项目,只是简单的实现录入数据功能