A note about the authorship of Ecclesiastes. Scholars don't know who wrote Ecclesiastes so it would be tenuous to apply everything written to Solomon.
Here is a quote from Michael V. Fox's commentary of Ecclesiastes (or Hebrew, Qohelet - which can mean 'teacher to the public'):
"Koheleth was traditionally identified with Solomon...since the nineteenth century, critical scholarship has not regarded Solomon as the actual author. Though modern scholars do not think that Koheleth was Solomon, almost all of them believe that the author wants us to make that identification.
You can check out a short video regarding who wrote Ecclesiastes, from an Old Testament scholar/professor, John Walton, here