sql语句:
`set @original_price=(select group_price from group_data where group_id=4 limit 1);
set @favorable_price=(select vip_favorable_price from group_data where group_id=4 and vip_favorable_price_start_date<now() and vip_favorable_price_expire_date >now() limit 1);
set @card=(SELECT coupon_list.coupon_value from card_record,coupon_list where card_record.card_user='asd' and card_record.coupon_status=0 and card_record.coupon_id=coupon_list.id and (coupon_list.coupon_type=0 or coupon_list.coupon_type=4) limit 1);
select convert(if(false and !ISNULL(@card),@original_price-@card,IFNULL(@favorable_price,@original_price)),decimal(5,2));`
代码大致如下:
` final Connection conn = getConn();
final PreparedStatement pstmt = conn.prepareStatement(sql);
final ResultSet rs = pstmt.executeQuery(sql)
ArrayList<Object> r= new ArrayList<Object>()
r.add(rs);
r.add(pstmt);
r.add(conn);
final ResultSet rs = (ResultSet) r.get(0);
if (rs.next()) {
return rs.getBigDecimal(1);
} else {
return null;
}
`
可是会报以下错,请问jdbc在不使用调用函数或存储过程的前提下能否执行如上格式的多行语句?
`java.sql.SQLException: ResultSet is from UPDATE. No Data.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)`