Stellar metallicity of star-forming galaxies at z ~ 3