0

I thought I did everything right, but for some reason my code will not connect to the database? I have 4 different files of java code you may have to look over to see if what is wrong. I'm not sure if there is a way for me to upload files for others to view.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

Not sure if it is my database file that may have something missing or not. When I hit Clean & Build, it does not show me any errors.

Update: Getting this error now

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:195)
    at controller.DataBaseConnectivity.intializeDB(DataBaseConnectivity.java:18)
    at controller.Controller.main(Controller.java:12)
Java Result: 1
  • You are getting an error message/exception ? So post the error message and add the significant code where the error occurs by editing your question. – PeterMmm May 15 '19 at 20:00
  • I have. java.lang.ClassNotFoundException: com.mysql.jdbc.Driver It will not connect to the database. I hit Clean & Build and it does not show me any errors. I am not sure which file I should be looking into as I have 4 java files. – Ahmed Archambault May 15 '19 at 20:56
  • Have you added the mysql connector dependency in your pom.xml? It seems to be missing. – Islam Hassan May 15 '19 at 21:04
  • Ok so now I am getting this error when I try to run the build: – Ahmed Archambault May 16 '19 at 02:07
  • The significant message in the stack trace is `Unsupported major.minor version 52.0`. See https://stackoverflow.com/a/35866015/2985643 . Presumably you compiled your code using JDK 8, but you are trying to run it in an environment with a JRE < 8. Check your project settings in NetBeans by selecting the project, right clicking and selecting _Properties_ from the context menu. – skomisa May 16 '19 at 02:50

0 Answers0