日期:2014-05-17 浏览次数:20716 次
String sql_1 = "select * from or_detail where orderId=? and productCode=?"
String str_1 = request.getParameter("orderId");
String str_2 = request.getParameter("productCode");
ResultSet rs_1 = (new JDBCutil()).execute(sql_1,str_1,str_2);
if(rs_1.next()){
double price = rs_1.getDouble("price");
double qty = rs_1.getDouble("qty");
}
//JDBCutil 的execute方法如下
public ResultSet execute(String sql ,String str_1,String st_2){
session = this.getSession();
ResuleSet rs = null;
try{
conn = session.connection();
pstat = conn.prepareStatement(sql);
pstat.setString(1,str_1);
pstat.setString(2,str_2);
rs_1 = pstat.executeQuery();
}catch(Exception e){
e.printStackTrace();
}
return rs_1;
}