Code example for PreparedStatement

Methods: executeUpdate, setFloat, setInt

0
		PreparedStatement pstmt = null;
		String sql = "insert into t_food_order(foodId,orderId,quantity) values(?,?,?)";
		try { 
			conn = DButil2.getConnection();
			pstmt = DButil2.getPreparedStatement(conn, sql);
			pstmt.setInt(1, foodId);
			pstmt.setInt(2,orderId);
			pstmt.setFloat(3, quantity);
			pstmt.executeUpdate();
			return true; 
			 
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{ 
			DButil2.closeStatement(pstmt);
			DButil2.closeConnection(conn);
			 
		} 
		return false; 
	} 
	//ÏÔʾËùÓж©µ¥,¶à±í²éѯ¡£