Both sentences are correct and natural, or you could say 'That gave a real boost to my confidence' or 'That gave my confidence a real boost'.
'Gain confidence', 'gain in confidence', 'develop confidence', and 'acquire confidence' can all be used. 'Get' and 'obtain' are not natural.