Help?

So yesterday I had sex with my boyfriend, for the first time it felt uncomfortable and hurt a bit. At the time I had to go pee and also my stomach was acting up all day (gas in my stomach and I had to go the number 2). During the week I had the stomach flu, constipation and I also didn’t have sex for a couple days. Due to that. We’re both std free etc, and I don’t have a UTI. So I’m wondering if it felt uncomfortable due to me having to go pee during sex or because I needed to use the bathroom(#2). This hasn’t ever happened to us. I was also thinking it might of been due to lack of lubrication but we did foreplay and used lube. I felt bad because we had to stop and didn’t get to finish but my boyfriend understood.