为什么user_id会是空啊? com.microsoft.sqlserver.jdbc.SQLServerException: 该语句没有返回结果集。
try{con=this.getConnection();Stringsql="insertintoT_Ordervalues(?,?,?);select@@identi...
try{
con=this.getConnection();
String sql="insert into T_Order values(?,?,?);select @@identity AS user_id;";
pst=con.prepareStatement(sql);
pst.setInt(1, order.getOrderUid());
pst.setDate(2, new Date(order.getOrderXiaDanTime().getTime()));
pst.setDouble(3, order.getOrderTotalPrice());
//pst.executeUpdate();
rs=pst.executeQuery();
while(rs.next()){
return (rs.getInt(1));
}
} catch(Exception e){
e.printStackTrace();
} finally{
this.closeAll(con, pst, rs);
}
return 0;
} 展开
con=this.getConnection();
String sql="insert into T_Order values(?,?,?);select @@identity AS user_id;";
pst=con.prepareStatement(sql);
pst.setInt(1, order.getOrderUid());
pst.setDate(2, new Date(order.getOrderXiaDanTime().getTime()));
pst.setDouble(3, order.getOrderTotalPrice());
//pst.executeUpdate();
rs=pst.executeQuery();
while(rs.next()){
return (rs.getInt(1));
}
} catch(Exception e){
e.printStackTrace();
} finally{
this.closeAll(con, pst, rs);
}
return 0;
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询