Is my boyfriend’s ED physical or emotional? What can we do?

Patient: My boyfriend and I have been together for 9 mos and have not been able to have intercourse. Im 29 and he is 33. We both have had intercourse in the past. He says he started having problems in this area a few months before we started dating. Ive read lot of sites and it seems its either emotional or health related. Im really confused though. He does get hard durning the night, usually a few times in the night and early morning. But when we go to insert he almost instintly goes soft, I try to lube up and make it as easy as possible. I just dont know. He says he has problems ejaculating as well, he says most of the time he doesnt cum, and sometimes it doesnt get hard at all for him. When we have foreplay sometimes he will be hard when I go down on him but he never reaches climax, it eventually goes limp. Sometimes during foreplay it doesnt get hard at all. He can usually satisfy me, you know with other methods, and seems to enjoy himself while particiapating but I cant seem to satisfy him…….im trying not to get frustrated but I really dont know what to do. Recently he said there is a pain on the back of his thighs when we try, he also says it doesnt seem to matter which position we try……any ideas?