I'm starting learning java (after many years of PHP) and I have some hard time trying to understand this java behavior.
I'm using jdk-8u121-macosx-x64 with mysql-connector-java-5.1.40-bin.jar registered in libraries property of my project in Intellij Idea 2016.3 CE.
If i try to connect as the picture below, i got a build error:
Bu if i put the same code inside a try catch block it works ok and i can query database with no problems:
It is really necessary to put every query inside a try catch block? Is this an intended method by java or i'm doing something wrong?
Thanks