时间:2021-07-01 10:21:17 帮助过:18人阅读
String inssql = "insert into buy(empid, name, dept) values (?, ?, ?,?)";
stmt = conn.prepareStatement(inssql);
stmt.setString(1, name);
stmt.setString(2, procuct);
stmt.setInt(3, quantity);
stmt.execute();
}
catch (Exception e)
{
System.out.println("SQLException was thrown: " + e.getMessage());
}
finally //close connections and {
try {
if(stmt != null)
stmt.close();
if(conn != null)
conn.close();
} catch (SQLException sqle) {
System.out.println("SQLException was thrown: " + sqle.getMessage());
}
}
}
%>
在该JSP文件中加上: <%@ page isThreadSafe="false" %>,使它以单线程方式执行,这时,仍然只有一个实例,所有客户端的请求以串行方 式执行。这样会降低系统的性能.
name=request.getParameter("name");
product=request.getParameter("product");
quantity=request.getParameter("quantity");
savebuy(name,product,quantity)
%>