Every time I open a connection to mysql database to perform some query I have to put this code before:
Class.forName("com.mysql.cj.jdbc.Driver");
otherwise I got this error:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/
Example:
Class.forName("com.mysql.cj.jdbc.Driver");
try (Connection conn = DriverManager.getConnection(Data.URL.getValue(), Data.USER.getValue(), Data.PASS.getValue())) {
DSLContext create = DSL.using(conn, SQLDialect.MYSQL);
My j-connector jar is in the web-inf lib forlder already. Do I really have to load the drivers explicitally every time or there is a better way to do this?