My two year old Nelson just loves the water!, but it took a bit of coaxing to get him to swim in water beyond his depth.
To teach him we took him to a dog "swimming pool" and used a floating ring (much like a frisbee) as enticement. Once that got his focus he very quickly got the hang of swimming and can easily keep his head and all of his neck out of the water with powerful swimming strokes.
To start them off, have them on a long lead and have someone else to hold a toy they really like a lot to get their attention. Get them into the water and have the toy holder walk/run around the pool holding the toy over the water just out of reach so the dog has to swim to go after it. The lead holder should be pulling on the lead "dragging" the dog forward through the water so it gets the idea of what to do and doesn't just flail away and sink. Once they get confident there's no stopping them and you can dispense with the lead pulling and even the lead all together.
Now when we go for a walk, if we are anywhere near a lake or the sea, we have to keep Nelson on lead because he will just take off for a swim. Not the best of things to do in the middle of winter, getting all cold, wet and muddy!
Interestingly, our other boxer, 8yo Natasha was always afraid of going beyond her depth and when we tried the swimming lessons (before we found out about the toy focus technique) she was a real sinker, Titanic 2! Paddle furiously with her front legs to no effect, no motion with her back legs, her head and chest would rise up, bum sink and then just slide backwards underwater, little bubbles rising from her nose as she headed towards the bottom. Then we had to pull desperately on the lead to get her to the surface again. Funniest thing you ever saw.
Now, however after seeing Nelson do so well she can suddenly swim! Wonders never cease! Not to be outdone by the younger dog, I think she decided to show she could do it if she really had too. So she has gone from being a fishing sinker and afraid of any depth beyond her chest for the first 8 years of her life to an accomplished swimmer overnight. Must be her mean streak
Anyway if you persist and use the right methods your dog can easily learn to swim and even love the water, although you have to watch them closely if the are off lead near rivers, lakes etc. They have no idea of the potential dangers and will happily leap in without a second thought.