I have read all possible answer here and here and here. I believe I have a problem somewhere else and it may useful to others also.
I have a Java Servlet and it was executing well in eclipse IDE but later I shifted the project to Netbeans. I imported MySQL JDBC driver in Libraries and using the code below for connection
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bolsms", "root", "@#$5869@#$");
but I am getting this error No suitable driver found for jdbc:mysql://localhost:3306/bolsms
I looking for answer for two days and community will appreciate that I am not repeating the question.
Edit 1:
Use a web browser to visit the MySQL download site and locate the source and binary download link for the archive format that you want to use (typically zip for Microsoft Windows systems or a gzipped tarball for Linux systems). Click that link to initiate the download process. Registration may be required.
When you use it in Tomcat you have to explicitly load jdbc driver. I experienced the same error in a servlet in Tomcat. And adding Class.forName("com.mysql.jdbc.Driver");
solve it.
The other thing I think, is to put the jar file in your WEB-INF/lib
, then in your project properties, in Libraries, add the JAR you store in WEB-INF/lib
.
To create the lib
directory, right click on WEB-INF
and choose New -> Folder...
If you don't see Folder
choose Other
then in the new windows choose Other
again and Folder
.
The Tomcat / JDBC issue is referenced here for more information.
Include the following piece of code in your code:
Class.forName("com.mysql.jdbc.Driver");//load driver
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/bolsms", "root", "@#$5869@#$");//connect to the database
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With