Question: I have read all possible answer [here](https://stackoverflow.com/questions/4533317/netbeans-with-glassfish-have-no-suitable-driver-found-for-mysqljdbc) and [here](https://stackoverflow.com/questions/9622105/java-sql-sqlexception-no-suitable-driver-found-for-netbeans) and [here](https://stackoverflow.com/questions/2839321/java-connectivity-with-mysql/2840358#2840358). 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:**

![MySQL JDBC driver in Libraries Folder](https://i.stack.imgur.com/zPMUL.jpg)

Answer: 
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

```
Check to make sure that your mysql-connector-java-(version)-bin.jar is here:

C:\Murach\Servlets and JSP\jsp2\_allfiles\servlet\_jsp\netbeans\ex\_starts\ch14sqlGateway\build\web\WEB-INF\lib

Also check to see if it is in here:

C:\Murach\Servlets and JSP\jsp2\_allfiles\servlet\_jsp\netbeans\ex\_starts\ch14sqlGateway\web\WEB-INF\lib

If it's not, paste your mysql driver jar into those directories and see if that works. 

After that, make sure you're explicitly loading the driver:

Class.forName("com.mysql.jdbc.Driver");