My olds is having a problem with starting. on 1997 Oldsmobile LSS

Rookie cbe0621eac06868b3efe0d8d1d3611e23c60d3114864ea2ec19a68cfbd3eebab
You can start it and without reason it will shut off and you can not restart it untill you disconnect the battery and wait about 3-5 minutes and then attach the cables. It will restart at that time. It seems to start for a number of times but then it starts over again. Disconnect and connect battery. It tries to start but won't with out disconnecting the battery. What is wrong? Put in new battery.
(2) Answers
Has the check engine light been on before you disconnected the battery? If it comes on again get a scan test without discon. battery! Also try unhooking the mass air flow sensor to see if that helps, they give a lot of trouble! Square, flat 3 wire sensor mounted on top of the intake just after the big rubber intake tube. Search ebay for picture, maybe youtube.
Sounds like a grounding issue. Very curious to know what the problem was. (Apologies for late response but I've just found and registered to this site.)