What is wrong with the code there are lots of error while debugging. I am writing a code for a singleton class to connect with the database mysql.
Here is my code
The driver connector is not in your build path. Configure the build path and point it to the 'mysql-connector-java-5.1.25-bin.jar' (check the version which you are using). Alternatively you can use maven :D
You will have to include driver jar for MySQL MySQL Connector Jar in your classpath.
If you are using Eclipse: How to add dependent libraries in Eclipse
If you are using command line include the path to the driver jar using the -cp parameter of java.
java -cp C:\lib\* Main
If you got the error in your IDE(compile-time error), you need to add your mysql-connector jar file to your libs and add this to your referenced library of project too.
If you get this error when you are running it, then probably its because you have not included mysql-connector JAR file to your webserver's lib folder.
Add mysql-connector-java-5.1.25-bin.jar
to your classpath and also to your webserver's lib directory. Tomcat lib path is given as an example Tomcat 6.0\lib
It is because the WEB-INF folder does not exist at the location in the sub directory in the error. You either compile the application to use the WEB-INF folder under public_html OR copy the WEB-INF folder in sub folder as in the error above.
For Gradle-based projects you need a dependency on MySQL Java Connector:
dependencies {
compile 'mysql:mysql-connector-java:6.0.+'
}
In the project into the folder Libraries-->right click --> Add Library --> Mysqlconnector 5.1