Added mysql-connector-java-5.1.22-bin.jar to the library. Created a class, imported all the java.sql packages. Have public static void main and a constructor. In the main
, added the line ...
DriverManager.getConnection("jdbc:mysql://localhost/lookups", "root", "dummyPWd")
It does not throw an exception and I can do stuff with the database. Add the same line to the Constructor and I get an error:
No suitable driver found ...
Why would it work in main
method but not inside a class constructor?