Core strength is important, but also what gear are you riding in?
Your small ring, and middle ring (in front) aren't usually sufficient for riding no hands and maintaining balance whilst doing so. Switch to the big ring in front and a small ring in back and pedal at a decent speed. That is the only way I know of to get it done.

You can leave one hand on the bars (nothing is wrong with safety), which I recommend in urban areas. Master pulling the water bottle out one-handed and replacing it at low comfortable speeds. Not everyone needs to ride "no hands." Hydration and your personal safety are more important than looking cool.