Apologies if this question is asked a lot (I have used the search but couldn't find anything!)
I'm trying to connect to a mySQL database using the following code, but I keep getting a ClassNotFoundException: com.mysql.jdbc.Driver error.
I think it may be a problem with the mysql connector needing to be in the classpath, but as I intend to use migLayout, I need the classpath to be pointing to that.
My current classpath is ".;L\My Projects\MyJavaApps\miglayout-3.7"
I've added the 'mysql-connector-java-5.1.7-bin' file to the above folder in the hope that would satisfy it's need to be in the classpath, but it looks like it doesn't.
I've set the classpath as "...mysql-connector-java-5.1.7-bin.jar" and now it works.
However, I'm using miglayout in my application and the miglayout folder needs to be added to classpath for it to work.
I've tried adding the mysql-connector-java-5.1.7-bin.jar the miglayout folder and pointed the classpath to .jar. I can connect to the db this way, but cannot launch my miglayout application.
I then tried pointing the classpath to the miglayout folder (which has the .jar file in) and the miglayout app works, but I cannot connect to the db.
I know I'm doing something wrong, so how can I set it so I can have both working?
If as plain Java class using java.exe, you need to set the classpath using -cp or -classpath argument.
If as JAR file using java.exe -jar, you need to set the classpath in the manifest file.