David Farragut, Midshipman