0

I have read that when I open a connection on a MySQL database the instruction Class.forName("com.mysql.jdbc.Driver"); it was not necessary with the new drivers in fact the connection was opened without errors, after two years I took up the same project from my github.com repository and with the same software installed (MySQL, Apache Tomcat, etc.) the connection did not work without the Class.forName("com.mysql.jdbc.Driver"); instruction, On what it depends on? Why does it work once and another it does not work?

nitind
  • 19,089
  • 4
  • 34
  • 43
Davide Sestili
  • 101
  • 2
  • 9
  • The `Class.forName("...")` is not necessary anymore with newer Java versions / newer JDBC drivers. If you are using an older Java version and/or JDBC driver, it is still necessary. – Jesper Dec 11 '19 at 13:15
  • Could it be because I switched from Wildfly 10.1 to Tomcat 8.0.50? – Davide Sestili Dec 11 '19 at 14:53

1 Answers1

0

Are you using mysql connector J 8.0? The class name per the manual is com.mysql.cj.jdbc.Driver.

danblack
  • 12,130
  • 2
  • 22
  • 41