Just designed this, and it works pretty well, is foolproof and safe for dwarves, easy to do, doesn't require much setup (if you have an ocean or aquifer or an artificial infinite source already sitting around)
Basically, just build a swimming pool the size you want to hold sufficient dwarves at once. It can't be tooo big though, since it should be within the immediate "wave influence zone" of a single pump (maybe about 10 blocks max in any direction). Let's say, for example, a 10x7 room.
This is hooked up via a floodgate to a two story reservoir (with a roof one Z level higher than the pool), which is exactly 5/7 the size of the swimming pool in area, so in our example, 50 blocks in area, or perhaps 5x10. This room is constantly fed by the ocean or an aquifer or something.
The swimming pool then has a little balcony, with a pump on it, that pumps out water in the swimming pool and throws it off of a cliff or something (there won't be very much water). To train your dwarves:
1) get them in the room with a meeting area, burrow, or military order.
2) lock the door
3) One guy begins to pumps the pump on the balcony manually.
4) Another guy flips the floodgate open, which immediately floods the room to 5/7 depth, and sloshes the dwarves around, giving them swimming training. After that they stop moving on their own, though.
5) So you close the floodgate. Now the pump operator sucks them all over to the other side, and they slosh over that way, while the water is still deep enough for more swimming training.
6) Maybe 20 seconds later, the reservoir is recharged, and you can flood them again. This time it will go up to 6/7 since there is still some water left. No big deal, they still don't drown.
7) Repeat 2-3 times for "Adequate" swimming skill, and which point they should be perfectly able to not die if they fall in the water.
This is not the machine to use if you wanna make your guys into veritable Navy SEALS. For that you would want some sort of continuous flow automated dwarf swimming grinder. That's harder than it sounds, though. I tried forever, and they kept flowing through my grates (just like sea life does at 7/7) and getting stuck /drowning / not learning... This is for those who would like to give dwarves a fighting chance, but don't want to put in the effort of a crazy swimming grinder.